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-25 00:50:16 -07:00
committed by Victor Berchet
parent 86ba072758
commit 7c07bfff97
142 changed files with 565 additions and 774 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

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 {

View File

@ -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;

View File

@ -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,

View File

@ -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)}'`);
}
});

View File

@ -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)];

View File

@ -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;
}

View File

@ -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.`);
}
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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';

View File

@ -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 {

View File

@ -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) {

View File

@ -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);

View File

@ -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}`);
}
}
}

View File

@ -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;
}

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileIdentifierMap, CompileNgModuleMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata, CompileTypeMetadata} from './compile_metadata';
import {ListWrapper} from './facade/collection';
@ -303,7 +302,7 @@ export class NgModuleProviderAnalyzer {
(provider) => { this._getOrCreateLocalProvider(provider.token, provider.eager); });
if (this._errors.length > 0) {
const errorString = this._errors.join('\n');
throw new BaseException(`Provider parse errors:\n${errorString}`);
throw new Error(`Provider parse errors:\n${errorString}`);
}
return this._transformedProviders.values();
}

View File

@ -6,14 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Compiler, ComponentFactory, ComponentStillLoadingError, Injectable, Injector, ModuleWithComponentFactories, NgModuleFactory, OptionalMetadata, Provider, SchemaMetadata, SkipSelfMetadata, Type} from '@angular/core';
import {Console} from '../core_private';
import {Compiler, ComponentFactory, Injectable, Injector, ModuleWithComponentFactories, NgModuleFactory, OptionalMetadata, Provider, SchemaMetadata, SkipSelfMetadata, Type} from '@angular/core';
import {ComponentStillLoadingError} from '../core_private';
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileNgModuleMetadata, CompilePipeMetadata, ProviderMeta, createHostComponentMeta} from './compile_metadata';
import {CompilerConfig} from './config';
import {DirectiveNormalizer} from './directive_normalizer';
import {BaseException} from './facade/exceptions';
import {isBlank, stringify} from './facade/lang';
import {CompileMetadataResolver} from './metadata_resolver';
import {NgModuleCompiler} from './ng_module_compiler';
@ -223,10 +220,10 @@ export class RuntimeCompiler implements Compiler {
this._compiledTemplateCache.get(compType);
if (!compiledTemplate) {
if (isHost) {
throw new BaseException(
throw new Error(
`Illegal state: Compiled view for component ${stringify(compType)} does not exist!`);
} else {
throw new BaseException(
throw new Error(
`Component ${stringify(compType)} is not part of any NgModule or the module has not been imported into your module.`);
}
}
@ -236,7 +233,7 @@ export class RuntimeCompiler implements Compiler {
private _assertComponentLoaded(compType: any, isHost: boolean): CompiledTemplate {
const compiledTemplate = this._assertComponentKnown(compType, isHost);
if (compiledTemplate.loading) {
throw new BaseException(
throw new Error(
`Illegal state: CompiledTemplate for ${stringify(compType)} (isHost: ${isHost}) is still loading!`);
}
return compiledTemplate;
@ -335,7 +332,7 @@ class CompiledTemplate {
});
this.proxyViewFactory = (...args: any[]) => {
if (!this._viewFactory) {
throw new BaseException(
throw new Error(
`Illegal state: CompiledTemplate for ${stringify(this.compType)} is not compiled yet!`);
}
return this._viewFactory.apply(null, args);
@ -355,7 +352,7 @@ class CompiledTemplate {
get normalizedCompMeta(): CompileDirectiveMetadata {
if (this.loading) {
throw new BaseException(`Template is still loading for ${this.compType.name}!`);
throw new Error(`Template is still loading for ${this.compType.name}!`);
}
return this._normalizedCompMeta;
}
@ -370,7 +367,7 @@ class CompiledTemplate {
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.`);
}
}

View File

@ -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 {StringWrapper, isBlank, isPresent} from './facade/lang';
@ -50,7 +49,7 @@ export class CssSelector {
while (isPresent(match = _SELECTOR_REGEXP.exec(selector))) {
if (isPresent(match[1])) {
if (inNot) {
throw new BaseException('Nesting :not is not allowed in a selector');
throw new Error('Nesting :not is not allowed in a selector');
}
inNot = true;
current = new CssSelector();
@ -71,7 +70,7 @@ export class CssSelector {
}
if (isPresent(match[7])) {
if (inNot) {
throw new BaseException('Multiple selectors in :not are not supported');
throw new Error('Multiple selectors in :not are not supported');
}
_addResult(results, cssSelector);
cssSelector = current = new CssSelector();

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, Inject, Injectable, OpaqueToken, Optional, SchemaMetadata, SecurityContext} from '@angular/core';
import {Inject, Injectable, OpaqueToken, Optional, SchemaMetadata, SecurityContext} from '@angular/core';
import {Console, MAX_INTERPOLATION_VALUES} from '../../core_private';
import {CompileDirectiveMetadata, CompilePipeMetadata, CompileTokenMetadata, removeIdentifierDuplicates} from '../compile_metadata';
@ -107,7 +107,7 @@ export class TemplateParser {
}
if (errors.length > 0) {
const errorString = errors.join('\n');
throw new BaseException(`Template parse errors:\n${errorString}`);
throw new Error(`Template parse errors:\n${errorString}`);
}
return result.templateAst;
@ -236,8 +236,7 @@ class TemplateParseVisitor implements html.Visitor {
this._checkPipes(ast, sourceSpan);
if (isPresent(ast) &&
(<Interpolation>ast.ast).expressions.length > MAX_INTERPOLATION_VALUES) {
throw new BaseException(
`Only support at most ${MAX_INTERPOLATION_VALUES} interpolation values!`);
throw new Error(`Only support at most ${MAX_INTERPOLATION_VALUES} interpolation values!`);
}
return ast;
} catch (e) {

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileIdentifierMap, CompileIdentifierMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata} from '../compile_metadata';
import {ListWrapper, StringMapWrapper} from '../facade/collection';

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {CompilePipeMetadata} from '../compile_metadata';
import {isBlank, isPresent} from '../facade/lang';
@ -86,7 +85,7 @@ function _findPipeMeta(view: CompileView, name: string): CompilePipeMetadata {
}
}
if (isBlank(pipeMeta)) {
throw new BaseException(
throw new Error(
`Illegal state: Could not find pipe ${name} although the parser should have detected this error!`);
}
return pipeMeta;

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import * as cdAst from '../expression_parser/ast';
import {isArray, isBlank, isPresent} from '../facade/lang';
@ -67,13 +66,13 @@ enum _Mode {
function ensureStatementMode(mode: _Mode, ast: cdAst.AST) {
if (mode !== _Mode.Statement) {
throw new BaseException(`Expected a statement, but saw ${ast}`);
throw new Error(`Expected a statement, but saw ${ast}`);
}
}
function ensureExpressionMode(mode: _Mode, ast: cdAst.AST) {
if (mode !== _Mode.Expression) {
throw new BaseException(`Expected an expression, but saw ${ast}`);
throw new Error(`Expected an expression, but saw ${ast}`);
}
}
@ -145,7 +144,7 @@ class _AstToIrVisitor implements cdAst.AstVisitor {
op = o.BinaryOperator.BiggerEquals;
break;
default:
throw new BaseException(`Unsupported operation ${ast.operation}`);
throw new Error(`Unsupported operation ${ast.operation}`);
}
return convertToStatementIfNeeded(
@ -273,7 +272,7 @@ class _AstToIrVisitor implements cdAst.AstVisitor {
if (receiver === this._implicitReceiver) {
var varExpr = this._nameResolver.getLocal(ast.name);
if (isPresent(varExpr)) {
throw new BaseException('Cannot assign to a reference or variable!');
throw new Error('Cannot assign to a reference or variable!');
}
}
return convertToStatementIfNeeded(
@ -291,7 +290,7 @@ class _AstToIrVisitor implements cdAst.AstVisitor {
visitAll(asts: cdAst.AST[], mode: _Mode): any { return asts.map(ast => this.visit(ast, mode)); }
visitQuote(ast: cdAst.Quote, mode: _Mode): any {
throw new BaseException('Quotes are not supported for evaluation!');
throw new Error('Quotes are not supported for evaluation!');
}
private visit(ast: cdAst.AST, mode: _Mode): any {
@ -466,7 +465,7 @@ class _AstToIrVisitor implements cdAst.AstVisitor {
private releaseTemporary(temporary: o.ReadVarExpr) {
this._currentTemporary--;
if (temporary.name != temporaryName(this.bindingIndex, this._currentTemporary)) {
throw new BaseException(`Temporary ${temporary.name} released out of order`);
throw new Error(`Temporary ${temporary.name} released out of order`);
}
}
}

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {CompileDirectiveMetadata, CompileTokenMetadata} from '../compile_metadata';
import {isBlank, isPresent} from '../facade/lang';
@ -28,7 +27,7 @@ export function getPropertyInView(
viewProp = viewProp.prop('parent');
}
if (currView !== definedView) {
throw new BaseException(
throw new Error(
`Internal error: Could not calculate a property in a parent view: ${property}`);
}
if (property instanceof o.ReadPropExpr) {
@ -86,7 +85,7 @@ export function createPureProxy(
var pureProxyId =
argCount < Identifiers.pureProxies.length ? Identifiers.pureProxies[argCount] : null;
if (isBlank(pureProxyId)) {
throw new BaseException(`Unsupported number of argument for pure functions: ${argCount}`);
throw new Error(`Unsupported number of argument for pure functions: ${argCount}`);
}
view.createMethod.addStmt(
o.THIS_EXPR.prop(pureProxyProp.name).set(o.importExpr(pureProxyId).callFn([fn])).toStmt());

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {afterEach, beforeEach, ddescribe, describe, expect, iit, it, xit} from '../../../core/testing/testing_internal';
import {CssBlockAst, CssBlockDefinitionRuleAst, CssBlockRuleAst, CssDefinitionAst, CssInlineRuleAst, CssKeyframeDefinitionAst, CssKeyframeRuleAst, CssMediaQueryRuleAst, CssSelectorRuleAst, CssStyleSheetAst, CssStyleValueAst} from '../../src/css_parser/css_ast';
@ -29,7 +28,7 @@ export function main() {
var output = parse(css);
var errors = output.errors;
if (errors.length > 0) {
throw new BaseException(errors.map((error: CssParseError) => error.msg).join(', '));
throw new Error(errors.map((error: CssParseError) => error.msg).join(', '));
}
return output.ast;
}

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {afterEach, beforeEach, ddescribe, describe, expect, iit, it, xit} from '../../../core/testing/testing_internal';
import {CssAst, CssAstVisitor, CssAtRulePredicateAst, CssBlockAst, CssBlockDefinitionRuleAst, CssBlockRuleAst, CssDefinitionAst, CssInlineRuleAst, CssKeyframeDefinitionAst, CssKeyframeRuleAst, CssMediaQueryRuleAst, CssPseudoSelectorAst, CssRuleAst, CssSelectorAst, CssSelectorRuleAst, CssSimpleSelectorAst, CssStyleSheetAst, CssStyleValueAst, CssStylesBlockAst, CssUnknownRuleAst, CssUnknownTokenListAst} from '../../src/css_parser/css_ast';
@ -122,7 +121,7 @@ export function main() {
var output = new CssParser().parse(cssCode, 'some-fake-css-file.css');
var errors = output.errors;
if (errors.length > 0 && !ignoreErrors) {
throw new BaseException(errors.map((error: CssParseError) => error.msg).join(', '));
throw new Error(errors.map((error: CssParseError) => error.msg).join(', '));
}
return output.ast;
}

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import * as html from '../../src/ml_parser/ast';
import {ParseTreeResult} from '../../src/ml_parser/html_parser';
import {ParseLocation} from '../../src/parse_util';
@ -14,7 +13,7 @@ import {ParseLocation} from '../../src/parse_util';
export function humanizeDom(parseResult: ParseTreeResult, addSourceSpan: boolean = false): any[] {
if (parseResult.errors.length > 0) {
var errorString = parseResult.errors.join('\n');
throw new BaseException(`Unexpected parse errors:\n${errorString}`);
throw new Error(`Unexpected parse errors:\n${errorString}`);
}
return humanizeNodes(parseResult.rootNodes, addSourceSpan);

View File

@ -9,13 +9,12 @@
// ATTENTION: This file will be overwritten with generated code by main()
import * as o from '@angular/compiler/src/output/output_ast';
import {TypeScriptEmitter} from '@angular/compiler/src/output/ts_emitter';
import {BaseException} from '@angular/core';
import {print} from '../../src/facade/lang';
import {assetUrl} from '../../src/util';
function unimplemented(): any {
throw new BaseException('unimplemented');
throw new Error('unimplemented');
}
import {SimpleJsImportGenerator, codegenExportsVars, codegenStmts} from './output_emitter_util';

View File

@ -8,7 +8,6 @@
// ATTENTION: This file will be overwritten with generated code by main()
import {JavaScriptEmitter} from '@angular/compiler/src/output/js_emitter';
import {BaseException} from '@angular/core';
import {print} from '../../src/facade/lang';
import {assetUrl} from '../../src/util';
@ -16,7 +15,7 @@ import {assetUrl} from '../../src/util';
import {SimpleJsImportGenerator, codegenExportsVars, codegenStmts} from './output_emitter_util';
export function getExpressions(): any {
throw new BaseException('unimplemented');
throw new Error('unimplemented');
}
// Generator

View File

@ -8,7 +8,7 @@
import {interpretStatements} from '@angular/compiler/src/output/output_interpreter';
import {jitStatements} from '@angular/compiler/src/output/output_jit';
import {BaseException, EventEmitter} from '@angular/core';
import {EventEmitter} from '@angular/core';
import {ViewType} from '@angular/core/src/linker/view_type';
import {beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
@ -179,7 +179,7 @@ export function main() {
() => { expect(expressions['throwError']).toThrowError('someError'); });
it('should support catching errors', () => {
function someOperation() { throw new BaseException('Boom!'); }
function someOperation() { throw new Error('Boom!'); }
var errorAndStack = expressions['catchError'](someOperation);
expect(errorAndStack[0].message).toEqual('Boom!');

View File

@ -10,7 +10,8 @@ import {CompileIdentifierMetadata} from '@angular/compiler/src/compile_metadata'
import * as o from '@angular/compiler/src/output/output_ast';
import {ImportGenerator} from '@angular/compiler/src/output/path_util';
import {assetUrl} from '@angular/compiler/src/util';
import {BaseException, EventEmitter} from '@angular/core';
import {EventEmitter} from '@angular/core';
import {BaseError} from '@angular/core/src/facade/errors';
import {ViewType} from '@angular/core/src/linker/view_type';
export class ExternalClass {
@ -34,8 +35,8 @@ var enumIdentifier = new CompileIdentifierMetadata({
runtime: ViewType.HOST
});
var baseExceptionIdentifier = new CompileIdentifierMetadata(
{name: 'BaseException', moduleUrl: assetUrl('core'), runtime: BaseException});
var baseErrorIdentifier = new CompileIdentifierMetadata(
{name: 'BaseError', moduleUrl: assetUrl('core', 'facade/errors'), runtime: BaseError});
export var codegenExportsVars = [
'getExpressions',
@ -68,8 +69,8 @@ var _getExpressionsStmts: o.Statement[] = [
.toDeclStmt(),
o.variable('throwError')
.set(o.fn([], [new o.ThrowStmt(o.importExpr(baseExceptionIdentifier).instantiate([o.literal(
'someError')]))]))
.set(o.fn([], [new o.ThrowStmt(
o.importExpr(baseErrorIdentifier).instantiate([o.literal('someError')]))]))
.toDeclStmt(),
o.variable('catchError')

View File

@ -7,7 +7,6 @@
*/
import {MetadataOverride} from '@angular/core/testing';
import {BaseException} from '../src/facade/exceptions';
import {stringify} from '../src/facade/lang';
type StringMap = {
@ -31,8 +30,7 @@ export class MetadataOverrider {
if (override.set) {
if (override.remove || override.add) {
throw new BaseException(
`Cannot set and add/remove ${stringify(metadataClass)} at the same time!`);
throw new Error(`Cannot set and add/remove ${stringify(metadataClass)} at the same time!`);
}
setMetadata(props, override.set);
}

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {ResourceLoader} from '../index';
import {ListWrapper, Map} from '../src/facade/collection';
@ -54,7 +53,7 @@ export class MockResourceLoader extends ResourceLoader {
*/
flush() {
if (this._requests.length === 0) {
throw new BaseException('No pending requests to flush');
throw new Error('No pending requests to flush');
}
do {
@ -76,7 +75,7 @@ export class MockResourceLoader extends ResourceLoader {
urls.push(expectation.url);
}
throw new BaseException(`Unsatisfied requests: ${urls.join(', ')}`);
throw new Error(`Unsatisfied requests: ${urls.join(', ')}`);
}
private _processRequest(request: _PendingRequest) {
@ -97,7 +96,7 @@ export class MockResourceLoader extends ResourceLoader {
return;
}
throw new BaseException(`Unexpected request ${url}`);
throw new Error(`Unexpected request ${url}`);
}
}