static-injector
Version:
Angular 依赖注入独立版本;Angular dependency injection standalone version
50 lines (49 loc) • 1.35 kB
TypeScript
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { InjectionToken } from './di/injection_token';
/**
* Provides a hook for centralized exception handling.
*
* The default implementation of `ErrorHandler` prints error messages to the `console`. To
* intercept error handling, write a custom exception handler that replaces this default as
* appropriate for your app.
*
* @usageNotes
* ### Example
*
* ```ts
* class MyErrorHandler implements ErrorHandler {
* handleError(error) {
* // do something with the exception
* }
* }
*
* // Provide in standalone apps
* bootstrapApplication(AppComponent, {
* providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
* })
*
* // Provide in module-based apps
* @NgModule({
* providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
* })
* class MyModule {}
* ```
*
* @publicApi
*
* @see [Unhandled errors in Angular](best-practices/error-handling)
*
*/
export declare class ErrorHandler {
handleError(error: any): void;
}
/**
* `InjectionToken` used to configure how to call the `ErrorHandler`.
*/
export declare const INTERNAL_APPLICATION_ERROR_HANDLER: InjectionToken<(e: any) => void>;