fix(errors): [2/2] Rename Exception to Error; remove from public API

BREAKING CHANGE:

Exceptions are no longer part of the public API. We don't expect that anyone should be referring to the Exception types.

ExceptionHandler.call(exception: any, stackTrace?: any, reason?: string): void;
change to:
ErrorHandler.handleError(error: any): void;
This commit is contained in:
Misko Hevery
2016-08-26 10:37:17 -07:00
committed by Victor Berchet
parent 86ba072758
commit 7c07bfff97
142 changed files with 565 additions and 774 deletions
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, ChangeDetectorRef, CollectionChangeRecord, DefaultIterableDiffer, Directive, DoCheck, EmbeddedViewRef, Input, IterableDiffer, IterableDiffers, OnChanges, SimpleChanges, TemplateRef, TrackByFn, ViewContainerRef} from '@angular/core';
import {ChangeDetectorRef, CollectionChangeRecord, DefaultIterableDiffer, Directive, DoCheck, EmbeddedViewRef, Input, IterableDiffer, IterableDiffers, OnChanges, SimpleChanges, TemplateRef, TrackByFn, ViewContainerRef} from '@angular/core';
import {getTypeNameForDebugging, isBlank, isPresent} from '../facade/lang';
@@ -112,7 +112,7 @@ export class NgFor implements DoCheck, OnChanges {
try {
this._differ = this._iterableDiffers.find(value).create(this._cdr, this.ngForTrackBy);
} catch (e) {
throw new BaseException(
throw new Error(
`Cannot find a differ supporting object '${value}' of type '${getTypeNameForDebugging(value)}'. NgFor only supports binding to Iterables such as Arrays.`);
}
}
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, Inject, Injectable, Optional} from '@angular/core';
import {Inject, Injectable, Optional} from '@angular/core';
import {isBlank} from '../facade/lang';
@@ -53,7 +53,7 @@ export class PathLocationStrategy extends LocationStrategy {
}
if (isBlank(href)) {
throw new BaseException(
throw new Error(
`No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.`);
}
@@ -9,7 +9,7 @@
import {ChangeDetectorRef, OnDestroy, Pipe, WrappedValue} from '@angular/core';
import {EventEmitter, Observable} from '../facade/async';
import {isBlank, isPresent, isPromise} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
interface SubscriptionStrategy {
createSubscription(async: any, updateLatestValue: any): any;
@@ -128,7 +128,7 @@ export class AsyncPipe implements OnDestroy {
} else if ((<any>obj).subscribe) {
return _observableStrategy;
} else {
throw new InvalidPipeArgumentException(AsyncPipe, obj);
throw new InvalidPipeArgumentError(AsyncPipe, obj);
}
}
@@ -11,8 +11,7 @@ import {Inject, LOCALE_ID, Pipe, PipeTransform} from '@angular/core';
import {StringMapWrapper} from '../facade/collection';
import {DateFormatter} from '../facade/intl';
import {DateWrapper, NumberWrapper, isBlank, isDate, isString} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
/**
@@ -102,7 +101,7 @@ export class DatePipe implements PipeTransform {
if (isBlank(value)) return null;
if (!this.supports(value)) {
throw new InvalidPipeArgumentException(DatePipe, value);
throw new InvalidPipeArgumentError(DatePipe, value);
}
if (NumberWrapper.isNumeric(value)) {
@@ -9,7 +9,7 @@
import {Pipe, PipeTransform} from '@angular/core';
import {StringWrapper, isBlank, isStringMap} from '../facade/lang';
import {NgLocalization, getPluralCategory} from '../localization';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
const _INTERPOLATION_REGEXP: RegExp = /#/g;
@@ -58,7 +58,7 @@ export class I18nPluralPipe implements PipeTransform {
if (isBlank(value)) return '';
if (!isStringMap(pluralMap)) {
throw new InvalidPipeArgumentException(I18nPluralPipe, pluralMap);
throw new InvalidPipeArgumentError(I18nPluralPipe, pluralMap);
}
const key = getPluralCategory(value, Object.keys(pluralMap), this._localization);
@@ -8,7 +8,7 @@
import {Pipe, PipeTransform} from '@angular/core';
import {isBlank, isStringMap} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
/**
*
@@ -47,7 +47,7 @@ export class I18nSelectPipe implements PipeTransform {
if (isBlank(value)) return '';
if (!isStringMap(mapping)) {
throw new InvalidPipeArgumentException(I18nSelectPipe, mapping);
throw new InvalidPipeArgumentError(I18nSelectPipe, mapping);
}
return mapping.hasOwnProperty(value) ? mapping[value] : '';
@@ -6,10 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, Type} from '@angular/core';
import {Type} from '@angular/core';
import {BaseError} from '../facade/errors';
import {stringify} from '../facade/lang';
export class InvalidPipeArgumentException extends BaseException {
export class InvalidPipeArgumentError extends BaseError {
constructor(type: Type<any>, value: Object) {
super(`Invalid argument '${value}' for pipe '${stringify(type)}'`);
}
@@ -8,7 +8,7 @@
import {Pipe, PipeTransform} from '@angular/core';
import {isBlank, isString} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
/**
@@ -25,7 +25,7 @@ export class LowerCasePipe implements PipeTransform {
transform(value: string): string {
if (isBlank(value)) return value;
if (!isString(value)) {
throw new InvalidPipeArgumentException(LowerCasePipe, value);
throw new InvalidPipeArgumentError(LowerCasePipe, value);
}
return value.toLowerCase();
}
@@ -11,7 +11,7 @@ import {Inject, LOCALE_ID, Pipe, PipeTransform, Type} from '@angular/core';
import {NumberFormatStyle, NumberFormatter} from '../facade/intl';
import {NumberWrapper, isBlank, isNumber, isPresent, isString} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
const _NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(\-(\d+))?)?$/;
@@ -22,7 +22,7 @@ function formatNumber(
// Convert strings to numbers
value = isString(value) && NumberWrapper.isNumeric(value) ? +value : value;
if (!isNumber(value)) {
throw new InvalidPipeArgumentException(pipe, value);
throw new InvalidPipeArgumentError(pipe, value);
}
let minInt: number;
let minFraction: number;
@@ -9,7 +9,7 @@
import {Pipe, PipeTransform} from '@angular/core';
import {ListWrapper} from '../facade/collection';
import {StringWrapper, isArray, isBlank, isString} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
/**
* Creates a new List or String containing only a subset (slice) of the
@@ -72,7 +72,7 @@ export class SlicePipe implements PipeTransform {
transform(value: any, start: number, end: number = null): any {
if (isBlank(value)) return value;
if (!this.supports(value)) {
throw new InvalidPipeArgumentException(SlicePipe, value);
throw new InvalidPipeArgumentError(SlicePipe, value);
}
if (isString(value)) {
return StringWrapper.slice(value, start, end);
@@ -8,7 +8,7 @@
import {Pipe, PipeTransform} from '@angular/core';
import {isBlank, isString} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
/**
* Implements uppercase transforms to text.
@@ -24,7 +24,7 @@ export class UpperCasePipe implements PipeTransform {
transform(value: string): string {
if (isBlank(value)) return value;
if (!isString(value)) {
throw new InvalidPipeArgumentException(UpperCasePipe, value);
throw new InvalidPipeArgumentError(UpperCasePipe, value);
}
return value.toUpperCase();
}
@@ -97,3 +97,7 @@ export var collectAndResolveStyles: typeof r.collectAndResolveStyles = r.collect
export var renderStyles: typeof r.renderStyles = r.renderStyles;
export type ViewMetadata = typeof _compiler_core_private_types.ViewMetadata;
export var ViewMetadata: typeof r.ViewMetadata = r.ViewMetadata;
export type ComponentStillLoadingError =
typeof _compiler_core_private_types.ComponentStillLoadingError;
export var ComponentStillLoadingError: typeof r.ComponentStillLoadingError =
r.ComponentStillLoadingError;
@@ -6,8 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AUTO_STYLE, BaseException} from '@angular/core';
import {ANY_STATE, AnimationOutput, DEFAULT_STATE, EMPTY_STATE} from '../../core_private';
import {CompileDirectiveMetadata} from '../compile_metadata';
import {StringMapWrapper} from '../facade/collection';
@@ -72,7 +70,7 @@ export class AnimationCompiler {
var errorMessageStr =
`Animation parsing for ${component.type.name} has failed due to the following errors:`;
groupedErrors.forEach(error => errorMessageStr += `\n- ${error}`);
throw new BaseException(errorMessageStr);
throw new Error(errorMessageStr);
}
animationCompilationCache.set(component, compiledAnimations);
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
import {ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
import {LifecycleHooks, reflector} from '../core_private';
@@ -17,7 +17,7 @@ import {getUrlScheme} from './url_resolver';
import {sanitizeIdentifier, splitAtColon} from './util';
function unimplemented(): any {
throw new BaseException('unimplemented');
throw new Error('unimplemented');
}
// group 0: "[prop] or (event) or @trigger"
@@ -269,7 +269,7 @@ export class CompileIdentifierMap<KEY extends CompileMetadataWithIdentifier, VAL
add(token: KEY, value: VALUE) {
var existing = this.get(token);
if (isPresent(existing)) {
throw new BaseException(
throw new Error(
`Cannot overwrite in a CompileIdentifierMap! Token: ${token.identifier.name}`);
}
this._tokens.push(token);
@@ -398,7 +398,7 @@ export class CompileTemplateMetadata {
this.animations = isPresent(animations) ? ListWrapper.flatten(animations) : [];
this.ngContentSelectors = isPresent(ngContentSelectors) ? ngContentSelectors : [];
if (isPresent(interpolation) && interpolation.length != 2) {
throw new BaseException(`'interpolation' should have a start and an end symbol.`);
throw new Error(`'interpolation' should have a start and an end symbol.`);
}
this.interpolation = interpolation;
}
+2 -2
View File
@@ -6,13 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, ViewEncapsulation, isDevMode} from '@angular/core';
import {ViewEncapsulation, isDevMode} from '@angular/core';
import {CompileIdentifierMetadata} from './compile_metadata';
import {Identifiers} from './identifiers';
function unimplemented(): any {
throw new BaseException('unimplemented');
throw new Error('unimplemented');
}
export class CompilerConfig {
@@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import * as chars from '../chars';
import {BaseError} from '../facade/errors';
import {StringWrapper, isPresent, resolveEnumToken} from '../facade/lang';
export enum CssTokenType {
@@ -86,7 +86,7 @@ export class CssLexer {
}
}
export class CssScannerError extends BaseException {
export class CssScannerError extends BaseError {
public rawMessage: string;
public message: string;
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, Injectable, ViewEncapsulation} from '@angular/core';
import {Injectable, ViewEncapsulation} from '@angular/core';
import {CompileDirectiveMetadata, CompileStylesheetMetadata, CompileTemplateMetadata, CompileTypeMetadata} from './compile_metadata';
import {CompilerConfig} from './config';
@@ -63,7 +63,7 @@ export class DirectiveNormalizer {
} else if (directive.template.templateUrl) {
normalizedTemplateAsync = this.normalizeTemplateAsync(directive.type, directive.template);
} else {
throw new BaseException(`No template specified for component ${directive.type.name}`);
throw new Error(`No template specified for component ${directive.type.name}`);
}
if (normalizedTemplateSync && normalizedTemplateSync.styleUrls.length === 0) {
// sync case
@@ -102,7 +102,7 @@ export class DirectiveNormalizer {
this._htmlParser.parse(template, directiveType.name, false, interpolationConfig);
if (rootNodesAndErrors.errors.length > 0) {
const errorString = rootNodesAndErrors.errors.join('\n');
throw new BaseException(`Template parse errors:\n${errorString}`);
throw new Error(`Template parse errors:\n${errorString}`);
}
const templateMetadataStyles = this.normalizeStylesheet(new CompileStylesheetMetadata({
styles: templateMeta.styles,
@@ -9,7 +9,6 @@
import {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, Injectable, InputMetadata, OutputMetadata, QueryMetadata, Type, resolveForwardRef} from '@angular/core';
import {ReflectorReader, reflector} from '../core_private';
import {StringMapWrapper} from './facade/collection';
import {BaseException} from './facade/exceptions';
import {isPresent, stringify} from './facade/lang';
import {splitAtColon} from './util';
@@ -41,7 +40,7 @@ export class DirectiveResolver {
}
}
if (throwIfNotFound) {
throw new BaseException(`No Directive annotation found on ${stringify(type)}`);
throw new Error(`No Directive annotation found on ${stringify(type)}`);
}
return null;
}
@@ -98,7 +97,7 @@ export class DirectiveResolver {
inputs.forEach((inputDef: string) => {
const publicName = this._extractPublicName(inputDef);
if (inputNames.indexOf(publicName) > -1) {
throw new BaseException(
throw new Error(
`Input '${publicName}' defined multiple times in '${stringify(directiveType)}'`);
}
});
@@ -116,7 +115,7 @@ export class DirectiveResolver {
outputs.forEach((outputDef: string) => {
const publicName = this._extractPublicName(outputDef);
if (outputNames.indexOf(publicName) > -1) {
throw new BaseException(
throw new Error(
`Output event '${publicName}' defined multiple times in '${stringify(directiveType)}'`);
}
});
@@ -14,7 +14,6 @@ import {StringMapWrapper} from '../src/facade/collection';
import {assertArrayOfStrings, assertInterpolationSymbols} from './assertions';
import * as cpl from './compile_metadata';
import {DirectiveResolver} from './directive_resolver';
import {BaseException} from './facade/exceptions';
import {isArray, isBlank, isPresent, isString, stringify} from './facade/lang';
import {Identifiers, identifierToken} from './identifiers';
import {hasLifecycleHook} from './lifecycle_reflector';
@@ -161,8 +160,7 @@ export class CompileMetadataResolver {
}
} else {
if (!selector) {
throw new BaseException(
`Directive ${stringify(directiveType)} has no selector, please add it!`);
throw new Error(`Directive ${stringify(directiveType)} has no selector, please add it!`);
}
}
@@ -235,12 +233,12 @@ export class CompileMetadataResolver {
if (importedModuleType) {
let importedMeta = this.getNgModuleMetadata(importedModuleType, false);
if (importedMeta === null) {
throw new BaseException(
throw new Error(
`Unexpected ${this._getTypeDescriptor(importedType)} '${stringify(importedType)}' imported by the module '${stringify(moduleType)}'`);
}
importedModules.push(importedMeta);
} else {
throw new BaseException(
throw new Error(
`Unexpected value '${stringify(importedType)}' imported by the module '${stringify(moduleType)}'`);
}
});
@@ -249,7 +247,7 @@ export class CompileMetadataResolver {
if (meta.exports) {
flattenArray(meta.exports).forEach((exportedType) => {
if (!isValidType(exportedType)) {
throw new BaseException(
throw new Error(
`Unexpected value '${stringify(exportedType)}' exported by the module '${stringify(moduleType)}'`);
}
let exportedDirMeta: cpl.CompileDirectiveMetadata;
@@ -262,7 +260,7 @@ export class CompileMetadataResolver {
} else if (exportedModuleMeta = this.getNgModuleMetadata(exportedType, false)) {
exportedModules.push(exportedModuleMeta);
} else {
throw new BaseException(
throw new Error(
`Unexpected ${this._getTypeDescriptor(exportedType)} '${stringify(exportedType)}' exported by the module '${stringify(moduleType)}'`);
}
});
@@ -275,7 +273,7 @@ export class CompileMetadataResolver {
if (meta.declarations) {
flattenArray(meta.declarations).forEach((declaredType) => {
if (!isValidType(declaredType)) {
throw new BaseException(
throw new Error(
`Unexpected value '${stringify(declaredType)}' declared by the module '${stringify(moduleType)}'`);
}
let declaredDirMeta: cpl.CompileDirectiveMetadata;
@@ -287,7 +285,7 @@ export class CompileMetadataResolver {
this._addPipeToModule(
declaredPipeMeta, moduleType, transitiveModule, declaredPipes, true);
} else {
throw new BaseException(
throw new Error(
`Unexpected ${this._getTypeDescriptor(declaredType)} '${stringify(declaredType)}' declared by the module '${stringify(moduleType)}'`);
}
});
@@ -343,13 +341,13 @@ export class CompileMetadataResolver {
private _verifyModule(moduleMeta: cpl.CompileNgModuleMetadata) {
moduleMeta.exportedDirectives.forEach((dirMeta) => {
if (!moduleMeta.transitiveModule.directivesSet.has(dirMeta.type.runtime)) {
throw new BaseException(
throw new Error(
`Can't export directive ${stringify(dirMeta.type.runtime)} from ${stringify(moduleMeta.type.runtime)} as it was neither declared nor imported!`);
}
});
moduleMeta.exportedPipes.forEach((pipeMeta) => {
if (!moduleMeta.transitiveModule.pipesSet.has(pipeMeta.type.runtime)) {
throw new BaseException(
throw new Error(
`Can't export pipe ${stringify(pipeMeta.type.runtime)} from ${stringify(moduleMeta.type.runtime)} as it was neither declared nor imported!`);
}
});
@@ -372,7 +370,7 @@ export class CompileMetadataResolver {
private _addTypeToModule(type: Type<any>, moduleType: Type<any>) {
const oldModule = this._ngModuleOfTypes.get(type);
if (oldModule && oldModule !== moduleType) {
throw new BaseException(
throw new Error(
`Type ${stringify(type)} is part of the declarations of 2 modules: ${stringify(oldModule)} and ${stringify(moduleType)}!`);
}
this._ngModuleOfTypes.set(type, moduleType);
@@ -529,7 +527,7 @@ export class CompileMetadataResolver {
let depsTokens =
dependenciesMetadata.map((dep) => { return dep ? stringify(dep.token) : '?'; })
.join(', ');
throw new BaseException(
throw new Error(
`Can't resolve all parameters for ${stringify(typeOrFunc)}: (${depsTokens}).`);
}
@@ -589,7 +587,7 @@ export class CompileMetadataResolver {
[]))
.join(', ');
throw new BaseException(
throw new Error(
`Invalid ${debugInfo ? debugInfo : 'provider'} - only instances of Provider and Type are allowed, got: [${providersInfo}]`);
}
if (compileProvider) {
@@ -603,11 +601,10 @@ export class CompileMetadataResolver {
let components: cpl.CompileTypeMetadata[] = [];
let collectedIdentifiers: cpl.CompileIdentifierMetadata[] = [];
if (provider.useFactory || provider.useExisting || provider.useClass) {
throw new BaseException(`The ANALYZE_FOR_ENTRY_COMPONENTS token only supports useValue!`);
throw new Error(`The ANALYZE_FOR_ENTRY_COMPONENTS token only supports useValue!`);
}
if (!provider.multi) {
throw new BaseException(
`The ANALYZE_FOR_ENTRY_COMPONENTS token only supports 'multi = true'!`);
throw new Error(`The ANALYZE_FOR_ENTRY_COMPONENTS token only supports 'multi = true'!`);
}
convertToCompileValue(provider.useValue, collectedIdentifiers);
collectedIdentifiers.forEach((identifier) => {
@@ -665,7 +662,7 @@ export class CompileMetadataResolver {
selectors = q.varBindings.map(varName => this.getTokenMetadata(varName));
} else {
if (!isPresent(q.selector)) {
throw new BaseException(
throw new Error(
`Can't construct a query for the property "${propertyName}" of "${stringify(typeOrFunc)}" since the query selector wasn't defined.`);
}
selectors = [this.getTokenMetadata(q.selector)];
@@ -9,7 +9,6 @@
import {Injectable, NgModuleMetadata, Type} from '@angular/core';
import {ReflectorReader, reflector} from '../core_private';
import {BaseException} from '../src/facade/exceptions';
import {isPresent, stringify} from './facade/lang';
function _isNgModuleMetadata(obj: any): obj is NgModuleMetadata {
@@ -31,7 +30,7 @@ export class NgModuleResolver {
return ngModuleMeta;
} else {
if (throwIfNotFound) {
throw new BaseException(`No NgModule metadata found for '${stringify(type)}'.`);
throw new Error(`No NgModule metadata found for '${stringify(type)}'.`);
}
return null;
}
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, SchemaMetadata} from '@angular/core';
import {SchemaMetadata} from '@angular/core';
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileNgModuleMetadata, CompilePipeMetadata, CompileProviderMetadata, CompileTokenMetadata, StaticSymbol, createHostComponentMeta} from './compile_metadata';
import {DirectiveNormalizer} from './directive_normalizer';
@@ -73,8 +73,7 @@ export class OfflineCompiler {
const compMeta = this._metadataResolver.getDirectiveMetadata(<any>compType);
const ngModule = ngModulesSummary.ngModuleByComponent.get(compType);
if (!ngModule) {
throw new BaseException(
`Cannot determine the module for component ${compMeta.type.name}!`);
throw new Error(`Cannot determine the module for component ${compMeta.type.name}!`);
}
return Promise
.all([compMeta, ...ngModule.transitiveModule.directives].map(
@@ -217,7 +216,7 @@ function _stylesModuleUrl(stylesheetUrl: string, shim: boolean, suffix: string):
function _assertComponent(meta: CompileDirectiveMetadata) {
if (!meta.isComponent) {
throw new BaseException(`Could not compile '${meta.type.name}' because it is not a component.`);
throw new Error(`Could not compile '${meta.type.name}' because it is not a component.`);
}
}
@@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {StringWrapper, isBlank, isPresent, isString} from '../facade/lang';
import * as o from './output_ast';
@@ -236,7 +235,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex
varName = CATCH_STACK_VAR.name;
break;
default:
throw new BaseException(`Unknown builtin variable ${ast.builtin}`);
throw new Error(`Unknown builtin variable ${ast.builtin}`);
}
}
ctx.print(varName);
@@ -332,7 +331,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex
opStr = '>=';
break;
default:
throw new BaseException(`Unknown operator ${ast.operator}`);
throw new Error(`Unknown operator ${ast.operator}`);
}
ctx.print(`(`);
ast.lhs.visitExpression(this, ctx);
@@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {isPresent} from '../facade/lang';
import {AbstractEmitterVisitor, CATCH_ERROR_VAR, CATCH_STACK_VAR, EmitterVisitorContext} from './abstract_emitter';
@@ -75,7 +74,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor {
if (ast.builtin === o.BuiltinVar.This) {
ctx.print('self');
} else if (ast.builtin === o.BuiltinVar.Super) {
throw new BaseException(
throw new Error(
`'super' needs to be handled at a parent ast node, not at the variable level!`);
} else {
super.visitReadVarExpr(ast, ctx);
@@ -161,7 +160,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor {
name = 'bind';
break;
default:
throw new BaseException(`Unknown builtin method: ${method}`);
throw new Error(`Unknown builtin method: ${method}`);
}
return name;
}
@@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {StringWrapper, evalExpression, isBlank, isPresent, isString} from '../facade/lang';
@@ -40,7 +39,7 @@ class JsEmitterVisitor extends AbstractJsEmitterVisitor {
visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any {
if (isBlank(ast.value.name)) {
throw new BaseException(`Internal error: unknown identifier ${ast.value}`);
throw new Error(`Internal error: unknown identifier ${ast.value}`);
}
if (isPresent(ast.value.moduleUrl) && ast.value.moduleUrl != this._moduleUrl) {
var prefix = this.importsWithPrefixes.get(ast.value.moduleUrl);
@@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {CompileIdentifierMetadata} from '../compile_metadata';
import {StringMapWrapper} from '../facade/collection';
@@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {ListWrapper} from '../facade/collection';
import {isPresent} from '../facade/lang';
@@ -104,7 +103,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor {
}
currCtx = currCtx.parent;
}
throw new BaseException(`Not declared variable ${expr.name}`);
throw new Error(`Not declared variable ${expr.name}`);
}
visitReadVarExpr(ast: o.ReadVarExpr, ctx: _ExecutionContext): any {
var varName = ast.name;
@@ -121,7 +120,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor {
varName = CATCH_STACK_VAR;
break;
default:
throw new BaseException(`Unknown builtin variable ${ast.builtin}`);
throw new Error(`Unknown builtin variable ${ast.builtin}`);
}
}
var currCtx = ctx;
@@ -131,7 +130,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor {
}
currCtx = currCtx.parent;
}
throw new BaseException(`Not declared variable ${varName}`);
throw new Error(`Not declared variable ${varName}`);
}
visitWriteKeyExpr(expr: o.WriteKeyExpr, ctx: _ExecutionContext): any {
var receiver = expr.receiver.visitExpression(this, ctx);
@@ -163,7 +162,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor {
result = receiver.bind(args[0]);
break;
default:
throw new BaseException(`Unknown builtin method ${expr.builtin}`);
throw new Error(`Unknown builtin method ${expr.builtin}`);
}
} else {
result = receiver[expr.name].apply(receiver, args);
@@ -281,7 +280,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor {
case o.BinaryOperator.BiggerEquals:
return lhs() >= rhs();
default:
throw new BaseException(`Unknown operator ${ast.operator}`);
throw new Error(`Unknown operator ${ast.operator}`);
}
}
visitReadPropExpr(ast: o.ReadPropExpr, ctx: _ExecutionContext): any {
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, Injectable} from '@angular/core';
import {Injectable} from '@angular/core';
import {Math, isBlank, isPresent} from '../facade/lang';
@@ -32,7 +32,7 @@ export class AssetUrl {
if (allowNonMatching) {
return null;
}
throw new BaseException(`Url ${url} is not a valid asset: url`);
throw new Error(`Url ${url} is not a valid asset: url`);
}
constructor(public packageName: string, public firstLevelDir: string, public modulePath: string) {
@@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {CompileIdentifierMetadata} from '../compile_metadata';
import {isArray, isBlank, isPresent} from '../facade/lang';
@@ -35,7 +34,7 @@ export function debugOutputAstAsTypeScript(ast: o.Statement | o.Expression | o.T
} else if (ast instanceof o.Type) {
ast.visitType(converter, ctx);
} else {
throw new BaseException(`Don't know how to print debug info for ${ast}`);
throw new Error(`Don't know how to print debug info for ${ast}`);
}
});
return ctx.toSource();
@@ -249,7 +248,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor
typeStr = 'string';
break;
default:
throw new BaseException(`Unsupported builtin type ${type.name}`);
throw new Error(`Unsupported builtin type ${type.name}`);
}
ctx.print(typeStr);
return null;
@@ -286,7 +285,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor
name = 'bind';
break;
default:
throw new BaseException(`Unknown builtin method: ${method}`);
throw new Error(`Unknown builtin method: ${method}`);
}
return name;
}
@@ -302,7 +301,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor
private _visitIdentifier(
value: CompileIdentifierMetadata, typeParams: o.Type[], ctx: EmitterVisitorContext): void {
if (isBlank(value.name)) {
throw new BaseException(`Internal error: unknown identifier ${value}`);
throw new Error(`Internal error: unknown identifier ${value}`);
}
if (isPresent(value.moduleUrl) && value.moduleUrl != this._moduleUrl) {
var prefix = this.importsWithPrefixes.get(value.moduleUrl);
@@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {CompileIdentifierMetadata} from '../compile_metadata';
import {StringMapWrapper} from '../facade/collection';
@@ -39,7 +38,7 @@ class _ValueOutputAstTransformer implements ValueTransformer {
} else if (value instanceof o.Expression) {
return value;
} else {
throw new BaseException(`Illegal state: Don't now how to compile value ${value}`);
throw new Error(`Illegal state: Don't now how to compile value ${value}`);
}
}
}
@@ -10,7 +10,6 @@ import {Injectable, PipeMetadata, Type, resolveForwardRef} from '@angular/core';
import {ReflectorReader, reflector} from '../core_private';
import {BaseException} from './facade/exceptions';
import {isPresent, stringify} from './facade/lang';
function _isPipeMetadata(type: any): boolean {
@@ -40,7 +39,7 @@ export class PipeResolver {
}
}
if (throwIfNotFound) {
throw new BaseException(`No Pipe decorator found on ${stringify(type)}`);
throw new Error(`No Pipe decorator found on ${stringify(type)}`);
}
return null;
}

Some files were not shown because too many files have changed in this diff Show More