本文整理汇总了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);
});