Skip to content

Commit 5c70a04

Browse files
arturovtAndrewKushnir
authored andcommitted
refactor(core): add token to missing injection context error message (angular#60009)
In this commit, we add injector token information to the error message to improve debugging and context awareness, because it is hard to capture the `inject()` stack trace in asynchronous contexts. PR Close angular#60009
1 parent 79ae355 commit 5c70a04

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/core/src/di/injector_compatibility.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function injectInjectorOnly<T>(
6868
throw new RuntimeError(
6969
RuntimeErrorCode.MISSING_INJECTION_CONTEXT,
7070
ngDevMode &&
71-
`inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with \`runInInjectionContext\`.`,
71+
`The \`${stringify(token)}\` token injection failed. \`inject()\` function must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with \`runInInjectionContext\`.`,
7272
);
7373
} else if (getCurrentInjector() === null) {
7474
return injectRootLimpMode(token, undefined, flags);

0 commit comments

Comments
 (0)