diff --git a/goldens/public-api/common/errors.md b/goldens/public-api/common/errors.md index 6b5547dcf3791..b194a0b3ee7ec 100644 --- a/goldens/public-api/common/errors.md +++ b/goldens/public-api/common/errors.md @@ -6,6 +6,8 @@ // @public export const enum RuntimeErrorCode { + // (undocumented) + INVALID_PIPE_ARGUMENT = 2100, // (undocumented) PARENT_NG_SWITCH_NOT_FOUND = 2000 } diff --git a/packages/common/src/errors.ts b/packages/common/src/errors.ts index ac763e1cb25fd..5e0e4ee3ce88e 100644 --- a/packages/common/src/errors.ts +++ b/packages/common/src/errors.ts @@ -13,4 +13,6 @@ export const enum RuntimeErrorCode { // NgSwitch errors PARENT_NG_SWITCH_NOT_FOUND = 2000, + // Pipe errors + INVALID_PIPE_ARGUMENT = 2100 } diff --git a/packages/common/src/pipes/invalid_pipe_argument_error.ts b/packages/common/src/pipes/invalid_pipe_argument_error.ts index e8c6e2ab1be64..5ae06508f84df 100644 --- a/packages/common/src/pipes/invalid_pipe_argument_error.ts +++ b/packages/common/src/pipes/invalid_pipe_argument_error.ts @@ -6,8 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ -import {Type, ɵstringify as stringify} from '@angular/core'; +import {Type, ɵRuntimeError as RuntimeError, ɵstringify as stringify} from '@angular/core'; + +import {RuntimeErrorCode} from '../errors'; export function invalidPipeArgumentError(type: Type, value: Object) { - return Error(`InvalidPipeArgument: '${value}' for pipe '${stringify(type)}'`); + const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? + `InvalidPipeArgument: '${value}' for pipe '${stringify(type)}'` : + ''; + return new RuntimeError(RuntimeErrorCode.INVALID_PIPE_ARGUMENT, errorMessage); } diff --git a/packages/common/test/pipes/number_pipe_spec.ts b/packages/common/test/pipes/number_pipe_spec.ts index ce025f5579b68..3aa7306b82ef0 100644 --- a/packages/common/test/pipes/number_pipe_spec.ts +++ b/packages/common/test/pipes/number_pipe_spec.ts @@ -64,9 +64,10 @@ import {ɵregisterLocaleData, ɵunregisterLocaleData} from '@angular/core'; it('should not support other objects', () => { expect(() => pipe.transform({} as any)) .toThrowError( - `InvalidPipeArgument: '[object Object] is not a number' for pipe 'DecimalPipe'`); + `NG02100: InvalidPipeArgument: '[object Object] is not a number' for pipe 'DecimalPipe'`); expect(() => pipe.transform('123abc')) - .toThrowError(`InvalidPipeArgument: '123abc is not a number' for pipe 'DecimalPipe'`); + .toThrowError( + `NG02100: InvalidPipeArgument: '123abc is not a number' for pipe 'DecimalPipe'`); }); }); @@ -108,7 +109,7 @@ import {ɵregisterLocaleData, ɵunregisterLocaleData} from '@angular/core'; it('should not support other objects', () => { expect(() => pipe.transform({} as any)) .toThrowError( - `InvalidPipeArgument: '[object Object] is not a number' for pipe 'PercentPipe'`); + `NG02100: InvalidPipeArgument: '[object Object] is not a number' for pipe 'PercentPipe'`); }); }); }); @@ -168,7 +169,7 @@ import {ɵregisterLocaleData, ɵunregisterLocaleData} from '@angular/core'; it('should not support other objects', () => { expect(() => pipe.transform({} as any)) .toThrowError( - `InvalidPipeArgument: '[object Object] is not a number' for pipe 'CurrencyPipe'`); + `NG02100: InvalidPipeArgument: '[object Object] is not a number' for pipe 'CurrencyPipe'`); }); it('should warn if you are using the v4 signature', () => { diff --git a/packages/core/test/bundling/router/bundle.golden_symbols.json b/packages/core/test/bundling/router/bundle.golden_symbols.json index ec401a45ca702..5839e225e88b9 100644 --- a/packages/core/test/bundling/router/bundle.golden_symbols.json +++ b/packages/core/test/bundling/router/bundle.golden_symbols.json @@ -1875,7 +1875,7 @@ "name": "stringify" }, { - "name": "stringify6" + "name": "stringify7" }, { "name": "stringifyCSSSelector"