MCPcopy Index your code
hub / github.com/angular/angular / prependTokenToDependencyPath

Function prependTokenToDependencyPath

packages/core/src/render3/errors_di.ts:85–105  ·  view source on GitHub ↗
(
  error: any,
  token: ProviderToken<unknown> | {multi: true; provide: ProviderToken<unknown>},
)

Source from the content-addressed store, hash-verified

83 * @param token Extra token that should be appended.
84 */
85export function prependTokenToDependencyPath(
86 error: any,
87 token: ProviderToken<unknown> | {multi: true; provide: ProviderToken<unknown>},
88): void {
89 error[NG_TOKEN_PATH] ??= [];
90 // Append current token to the current token path. Since the error
91 // is bubbling up, add the token in front of other tokens.
92 const currentPath = error[NG_TOKEN_PATH];
93 // Do not append the same token multiple times.
94 let pathStr: string;
95 if (typeof token === 'object' && 'multi' in token && token?.multi === true) {
96 assertDefined(token.provide, 'Token with multi: true should have a provide property');
97 pathStr = stringifyForError(token.provide);
98 } else {
99 pathStr = stringifyForError(token);
100 }
101
102 if (currentPath[0] !== pathStr) {
103 (error[NG_TOKEN_PATH] as string[]).unshift(pathStr);
104 }
105}
106
107/**
108 * Modifies an Error instance with an updated error message

Callers 1

getMethod · 0.90

Calls 2

assertDefinedFunction · 0.90
stringifyForErrorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…