errors.ts (angular-11.0.1) | : | errors.ts (angular-11.0.2) | ||
---|---|---|---|---|
/** | /** | |||
* @license | * @license | |||
* Copyright Google LLC All Rights Reserved. | * Copyright Google LLC All Rights Reserved. | |||
* | * | |||
* Use of this source code is governed by an MIT-style license that can be | * Use of this source code is governed by an MIT-style license that can be | |||
* found in the LICENSE file at https://angular.io/license | * found in the LICENSE file at https://angular.io/license | |||
*/ | */ | |||
import {InjectorType} from '../di/interface/defs'; | ||||
import {stringify} from '../util/stringify'; | ||||
import {RuntimeError, RuntimeErrorCode} from './error_code'; | import {RuntimeError, RuntimeErrorCode} from './error_code'; | |||
import {TNode} from './interfaces/node'; | import {TNode} from './interfaces/node'; | |||
import {LView, TVIEW} from './interfaces/view'; | import {LView, TVIEW} from './interfaces/view'; | |||
import {INTERPOLATION_DELIMITER, stringifyForError} from './util/misc_utils'; | import {INTERPOLATION_DELIMITER} from './util/misc_utils'; | |||
/** Called when directives inject each other (creating a circular dependency) */ | ||||
export function throwCyclicDependencyError(token: string, path?: string[]): neve | ||||
r { | ||||
const depPath = path ? `. Dependency path: ${path.join(' > ')} > ${token}` : ' | ||||
'; | ||||
throw new RuntimeError( | ||||
RuntimeErrorCode.CYCLIC_DI_DEPENDENCY, | ||||
`Circular dependency in DI detected for ${token}${depPath}`); | ||||
} | ||||
/** Called when there are multiple component selectors that match a given node * / | /** Called when there are multiple component selectors that match a given node * / | |||
export function throwMultipleComponentError(tNode: TNode): never { | export function throwMultipleComponentError(tNode: TNode): never { | |||
throw new RuntimeError( | throw new RuntimeError( | |||
RuntimeErrorCode.MULTIPLE_COMPONENTS_MATCH, | RuntimeErrorCode.MULTIPLE_COMPONENTS_MATCH, | |||
`Multiple components match node with tagname ${tNode.value}`); | `Multiple components match node with tagname ${tNode.value}`); | |||
} | } | |||
export function throwMixedMultiProviderError() { | ||||
throw new Error(`Cannot mix multi providers and regular providers`); | ||||
} | ||||
export function throwInvalidProviderError( | ||||
ngModuleType?: InjectorType<any>, providers?: any[], provider?: any) { | ||||
let ngModuleDetail = ''; | ||||
if (ngModuleType && providers) { | ||||
const providerDetail = providers.map(v => v == provider ? '?' + provider + ' | ||||
?' : '...'); | ||||
ngModuleDetail = | ||||
` - only instances of Provider and Type are allowed, got: [${providerDet | ||||
ail.join(', ')}]`; | ||||
} | ||||
throw new Error( | ||||
`Invalid provider for the NgModule '${stringify(ngModuleType)}'` + ngModul | ||||
eDetail); | ||||
} | ||||
/** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */ | /** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */ | |||
export function throwErrorIfNoChangesMode( | export function throwErrorIfNoChangesMode( | |||
creationMode: boolean, oldValue: any, currValue: any, propName?: string): ne ver|void { | creationMode: boolean, oldValue: any, currValue: any, propName?: string): ne ver|void { | |||
const field = propName ? ` for '${propName}'` : ''; | const field = propName ? ` for '${propName}'` : ''; | |||
let msg = | let msg = | |||
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${ | `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${ | |||
field}: '${oldValue}'. Current value: '${currValue}'.`; | field}: '${oldValue}'. Current value: '${currValue}'.`; | |||
if (creationMode) { | if (creationMode) { | |||
msg += | msg += | |||
` It seems like the view has been created after its parent and its child ren have been dirty checked.` + | ` It seems like the view has been created after its parent and its child ren have been dirty checked.` + | |||
skipping to change at line 123 | skipping to change at line 95 | |||
const matches = meta.match(new RegExp(INTERPOLATION_DELIMITER, 'g')); | const matches = meta.match(new RegExp(INTERPOLATION_DELIMITER, 'g')); | |||
// first interpolation delimiter separates property name from interpolatio n parts (in case of | // first interpolation delimiter separates property name from interpolatio n parts (in case of | |||
// property interpolations), so we subtract one from total number of found delimiters | // property interpolations), so we subtract one from total number of found delimiters | |||
if (matches && (matches.length - 1) > bindingIndex - idx) { | if (matches && (matches.length - 1) > bindingIndex - idx) { | |||
return constructDetailsForInterpolation(lView, idx, bindingIndex, meta, newValue); | return constructDetailsForInterpolation(lView, idx, bindingIndex, meta, newValue); | |||
} | } | |||
} | } | |||
} | } | |||
return {propName: undefined, oldValue, newValue}; | return {propName: undefined, oldValue, newValue}; | |||
} | } | |||
/** Throws an error when a token is not found in DI. */ | ||||
export function throwProviderNotFoundError(token: any, injectorName?: string): n | ||||
ever { | ||||
const injectorDetails = injectorName ? ` in ${injectorName}` : ''; | ||||
throw new RuntimeError( | ||||
RuntimeErrorCode.PROVIDER_NOT_FOUND, | ||||
`No provider for ${stringifyForError(token)} found${injectorDetails}`); | ||||
} | ||||
End of changes. 5 change blocks. | ||||
34 lines changed or deleted | 1 lines changed or added |