本文整理匯總了TypeScript中@angular/core.ErrorHandler類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ErrorHandler類的具體用法?TypeScript ErrorHandler怎麽用?TypeScript ErrorHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ErrorHandler類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: computeNextEntry
/**
* Computes the next entry in the log by applying an action.
*/
function computeNextEntry(
reducer: ActionReducer<any, any>,
action: Action,
state: any,
error: any,
errorHandler: ErrorHandler
) {
if (error) {
return {
state,
error: 'Interrupted by an error up the chain',
};
}
let nextState = state;
let nextError;
try {
nextState = reducer(state, action);
} catch (err) {
nextError = err.toString();
errorHandler.handleError(err.stack || err);
}
return {
state: nextState,
error: nextError,
};
}
示例2: reportInvalidActions
function reportInvalidActions(
output: EffectNotification,
reporter: ErrorHandler
) {
if (output.notification.kind === 'N') {
const action = output.notification.value;
const isInvalidAction = !isAction(action);
if (isInvalidAction) {
reporter.handleError(
new Error(
`Effect ${getEffectName(output)} dispatched an invalid action: ${
action
}`
)
);
}
}
}
示例3: reportErrorThrown
function reportErrorThrown(output: EffectNotification, reporter: ErrorHandler) {
if (output.notification.kind === 'E') {
reporter.handleError(output.notification.error);
}
}
示例4: catch
( event: T ) : void => {
try {
callback.call( callbackContext, event );
} catch ( error ) {
this.errorHandler.handleError( error );
}
}
示例5: normalizeError
// ---
// PRIVATE METHODS.
// ---
// Errors can occur for a variety of reasons. I normalize the error response so that
// the calling context can assume a standard error structure.
private normalizeError( error: any ) : ErrorResponse {
this.errorHandler.handleError( error );
// NOTE: Since I'm not really dealing with a production API, this doesn't really
// normalize anything (ie, this is not the focus of this demo).
return({
id: "-1",
code: "UnknownError",
message: "An unexpected error occurred."
});
}
示例6: handleError
handleError(err) {
this.modal.show({
title: 'Uncaught ' + (err.name || 'Error'),
body: `
<p>${err.message}</p>
<hr/>
<pre>${err.stack}</pre>
`,
secondaryButton: 'Okay',
height: 400,
width: 700
});
this.defaultHandler.handleError(err);
}
示例7: error
error(value: any, ...rest: any[]) {
const message = [value, ...rest].join(' ');
this.errorHandler.handleError(message);
}
示例8: error
error(error: Error) {
this.errorHandler.handleError(error);
}
示例9:
this._ngxsExecutionStrategy.leave(() => this._errorHandler.handleError(error))
示例10:
}, error => {
this.errorHandler.handleError(error);
});