MCPcopy Create free account
hub / github.com/angular/angular / _callAndReportToErrorHandler

Function _callAndReportToErrorHandler

packages/core/src/platform/bootstrap.ts:223–249  ·  view source on GitHub ↗
(
  errorHandler: (e: unknown) => void,
  ngZone: NgZone,
  envInjector: EnvironmentInjector,
  callback: () => any,
)

Source from the content-addressed store, hash-verified

221}
222
223function _callAndReportToErrorHandler(
224 errorHandler: (e: unknown) => void,
225 ngZone: NgZone,
226 envInjector: EnvironmentInjector,
227 callback: () => any,
228): any {
229 try {
230 const result = callback();
231 if (isPromise(result)) {
232 return result.catch((e: any) => {
233 if (!envInjector.destroyed) {
234 ngZone.runOutsideAngular(() => errorHandler(e));
235 }
236 // rethrow as the exception handler might not do it
237 throw e;
238 });
239 }
240
241 return result;
242 } catch (e) {
243 if (!envInjector.destroyed) {
244 ngZone.runOutsideAngular(() => errorHandler(e));
245 }
246 // rethrow as the exception handler might not do it
247 throw e;
248 }
249}

Callers 1

bootstrapFunction · 0.85

Calls 5

isPromiseFunction · 0.90
callbackFunction · 0.50
errorHandlerFunction · 0.50
catchMethod · 0.45
runOutsideAngularMethod · 0.45

Tested by

no test coverage detected