refactor(core): use RuntimeError to throw provider not found error (#40901)

This PR performs a small refactoring to use `RuntimeError` class and corresponding error code (by calling
`throwProviderNotFoundError` which formats the message) to make it more consistent with other places where
similar errors are thrown.

PR Close #40901
This commit is contained in:
Andrew Kushnir 2021-02-17 22:14:52 -08:00 committed by atscott
parent f340a5b9f2
commit d1d1dadb41
2 changed files with 5 additions and 1 deletions

View File

@ -7,6 +7,7 @@
*/
import {AbstractType, Type} from '../interface/type';
import {throwProviderNotFoundError} from '../render3/errors_di';
import {assertNotEqual} from '../util/assert';
import {stringify} from '../util/stringify';
import {InjectionToken} from './injection_token';
@ -62,7 +63,7 @@ export function injectRootLimpMode<T>(
}
if (flags & InjectFlags.Optional) return null;
if (notFoundValue !== undefined) return notFoundValue;
throw new Error(`Injector: NOT_FOUND [${stringify(token)}]`);
throwProviderNotFoundError(stringify(token), 'Injector');
}

View File

@ -47,6 +47,9 @@
{
"name": "R3Injector"
},
{
"name": "RuntimeError"
},
{
"name": "ScopedService"
},