refactor(core): drop component factory error in production (#60601)

Drops component factory error in production. Couldn't capture it before because of `throw Error` (without `new`).

PR Close #60601
This commit is contained in:
arturovt 2025-03-28 10:55:42 +02:00 committed by Jessica Janiuk
parent accc65c2c9
commit 2fe8f1a9de
5 changed files with 18 additions and 3 deletions

View file

@ -124,6 +124,8 @@ export const enum RuntimeErrorCode {
// (undocumented)
NO_BINDING_TARGET = 315,
// (undocumented)
NO_COMPONENT_FACTORY_FOUND = 917,
// (undocumented)
NO_SUPPORTING_DIFFER_FACTORY = 901,
// (undocumented)
OUTPUT_REF_DESTROYED = 953,

View file

@ -125,6 +125,7 @@ export const enum RuntimeErrorCode {
UNEXPECTED_ZONEJS_PRESENT_IN_ZONELESS_MODE = 914,
MISSING_NG_MODULE_DEFINITION = 915,
MISSING_DIRECTIVE_DEFINITION = 916,
NO_COMPONENT_FACTORY_FOUND = 917,
// Signal integration errors
REQUIRED_INPUT_NO_VALUE = -950,

View file

@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/
import {RuntimeError, RuntimeErrorCode} from '../errors';
import {Type} from '../interface/type';
import {stringify} from '../util/stringify';
@ -13,7 +14,12 @@ import type {ComponentFactory} from './component_factory';
class _NullComponentFactoryResolver implements ComponentFactoryResolver {
resolveComponentFactory<T>(component: {new (...args: any[]): T}): ComponentFactory<T> {
throw Error(`No component factory found for ${stringify(component)}.`);
throw new RuntimeError(
RuntimeErrorCode.NO_COMPONENT_FACTORY_FOUND,
typeof ngDevMode !== 'undefined' &&
ngDevMode &&
`No component factory found for ${stringify(component)}.`,
);
}
}

View file

@ -12,7 +12,13 @@ export function getClosureSafeProperty<T>(objWithPropertyToExtract: T): string {
return key;
}
}
throw Error('Could not find renamed property on target object.');
// Cannot change it to `RuntimeError` because the `util` target cannot
// circularly depend on the `core` target.
throw Error(
typeof ngDevMode !== 'undefined' && ngDevMode
? 'Could not find renamed property on target object.'
: '',
);
}
/**

View file

@ -698,7 +698,7 @@
"storeLViewOnDestroy",
"storeListenerCleanup",
"stringify",
"stringify13",
"stringify14",
"stringifyCSSSelector",
"stripTrailingSlash",
"subscribeOn",