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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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