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,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {Observable} from '../facade/async';
import {isPresent} from '../facade/lang';
import {AbstractControl} from '../model';
@ -19,7 +18,7 @@ import {AbstractControl} from '../model';
* @stable
*/
export abstract class AbstractControlDirective {
get control(): AbstractControl { throw new BaseException('unimplemented'); }
get control(): AbstractControl { throw new Error('unimplemented'); }
get value(): any { return isPresent(this.control) ? this.control.value : null; }

View File

@ -6,14 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {AbstractControlDirective} from './abstract_control_directive';
import {ControlValueAccessor} from './control_value_accessor';
import {AsyncValidatorFn, ValidatorFn} from './validators';
function unimplemented(): any {
throw new BaseException('unimplemented');
throw new Error('unimplemented');
}
/**

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, Directive, Host, Inject, Input, OnChanges, OnDestroy, Optional, Output, Self, SimpleChanges, forwardRef} from '@angular/core';
import {Directive, Host, Inject, Input, OnChanges, OnDestroy, Optional, Output, Self, SimpleChanges, forwardRef} from '@angular/core';
import {EventEmitter} from '../facade/async';
import {FormControl} from '../model';

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, Directive, Host, Inject, Input, OnDestroy, OnInit, Optional, Self, SkipSelf, forwardRef} from '@angular/core';
import {Directive, Host, Inject, Input, OnDestroy, OnInit, Optional, Self, SkipSelf, forwardRef} from '@angular/core';
import {NG_ASYNC_VALIDATORS, NG_VALIDATORS} from '../validators';

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, Directive, ElementRef, Injectable, Injector, Input, OnDestroy, OnInit, Renderer, forwardRef} from '@angular/core';
import {Directive, ElementRef, Injectable, Injector, Input, OnDestroy, OnInit, Renderer, forwardRef} from '@angular/core';
import {ListWrapper} from '../facade/collection';
import {isPresent} from '../facade/lang';
@ -139,7 +139,7 @@ export class RadioControlValueAccessor implements ControlValueAccessor,
}
private _throwNameError(): void {
throw new BaseException(`
throw new Error(`
If you define both a name and a formControlName attribute on your radio button, their values
must match. Ex: <input type="radio" formControlName="food" name="food">
`);

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, Directive, Inject, Input, OnChanges, Optional, Output, Self, SimpleChanges, forwardRef} from '@angular/core';
import {Directive, Inject, Input, OnChanges, Optional, Output, Self, SimpleChanges, forwardRef} from '@angular/core';
import {EventEmitter} from '../../facade/async';
import {ListWrapper, StringMapWrapper} from '../../facade/collection';

View File

@ -6,13 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {FormErrorExamples as Examples} from './error_examples';
export class ReactiveErrors {
static controlParentException(): void {
throw new BaseException(
throw new Error(
`formControlName must be used with a parent formGroup directive. You'll want to add a formGroup
directive and pass it an existing FormGroup instance (you can create one in your class).
@ -22,7 +21,7 @@ export class ReactiveErrors {
}
static ngModelGroupException(): void {
throw new BaseException(
throw new Error(
`formControlName cannot be used with an ngModelGroup parent. It is only compatible with parents
that also have a "form" prefix: formGroupName, formArrayName, or formGroup.
@ -35,7 +34,7 @@ export class ReactiveErrors {
${Examples.ngModelGroup}`);
}
static missingFormException(): void {
throw new BaseException(`formGroup expects a FormGroup instance. Please pass one in.
throw new Error(`formGroup expects a FormGroup instance. Please pass one in.
Example:
@ -43,7 +42,7 @@ export class ReactiveErrors {
}
static groupParentException(): void {
throw new BaseException(
throw new Error(
`formGroupName must be used with a parent formGroup directive. You'll want to add a formGroup
directive and pass it an existing FormGroup instance (you can create one in your class).
@ -53,7 +52,7 @@ export class ReactiveErrors {
}
static arrayParentException(): void {
throw new BaseException(
throw new Error(
`formArrayName must be used with a parent formGroup directive. You'll want to add a formGroup
directive and pass it an existing FormGroup instance (you can create one in your class).

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {ListWrapper, StringMapWrapper} from '../facade/collection';
import {hasConstructor, isBlank, isPresent, looseIdentical} from '../facade/lang';
@ -93,7 +92,7 @@ function _throwError(dir: AbstractControlDirective, message: string): void {
} else {
messageEnd = 'unspecified name attribute';
}
throw new BaseException(`${message} ${messageEnd}`);
throw new Error(`${message} ${messageEnd}`);
}
export function composeValidators(validators: /* Array<Validator|Function> */ any[]): ValidatorFn {

View File

@ -6,12 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {FormErrorExamples as Examples} from './error_examples';
export class TemplateDrivenErrors {
static modelParentException(): void {
throw new BaseException(`
throw new Error(`
ngModel cannot be used to register form controls with a parent formGroup directive. Try using
formGroup's partner directive "formControlName" instead. Example:
@ -25,7 +24,7 @@ export class TemplateDrivenErrors {
}
static formGroupNameException(): void {
throw new BaseException(`
throw new Error(`
ngModel cannot be used to register form controls with a parent formGroupName or formArrayName directive.
Option 1: Use formControlName instead of ngModel (reactive strategy):
@ -38,7 +37,7 @@ export class TemplateDrivenErrors {
}
static missingNameException() {
throw new BaseException(
throw new Error(
`If ngModel is used within a form tag, either the name attribute must be set or the form
control must be defined as 'standalone' in ngModelOptions.
@ -47,7 +46,7 @@ export class TemplateDrivenErrors {
}
static modelGroupParentException() {
throw new BaseException(`
throw new Error(`
ngModelGroup cannot be used with a parent formGroup directive.
Option 1: Use formGroupName instead of ngModelGroup (reactive strategy):

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException} from '@angular/core';
import {PromiseObservable} from 'rxjs/observable/PromiseObservable';
import {composeAsyncValidators, composeValidators} from './directives/shared';
@ -645,13 +644,13 @@ export class FormGroup extends AbstractControl {
/** @internal */
_throwIfControlMissing(name: string): void {
if (!Object.keys(this.controls).length) {
throw new BaseException(`
throw new Error(`
There are no form controls registered with this group yet. If you're using ngModel,
you may want to check next tick (e.g. use setTimeout).
`);
}
if (!this.controls[name]) {
throw new BaseException(`Cannot find form control with name: ${name}.`);
throw new Error(`Cannot find form control with name: ${name}.`);
}
}
@ -710,7 +709,7 @@ export class FormGroup extends AbstractControl {
_checkAllValuesPresent(value: any): void {
this._forEachChild((control: AbstractControl, name: string) => {
if (value[name] === undefined) {
throw new BaseException(`Must supply a value for form control with name: '${name}'.`);
throw new Error(`Must supply a value for form control with name: '${name}'.`);
}
});
}
@ -817,13 +816,13 @@ export class FormArray extends AbstractControl {
/** @internal */
_throwIfControlMissing(index: number): void {
if (!this.controls.length) {
throw new BaseException(`
throw new Error(`
There are no form controls registered with this array yet. If you're using ngModel,
you may want to check next tick (e.g. use setTimeout).
`);
}
if (!this.at(index)) {
throw new BaseException(`Cannot find form control at index ${index}`);
throw new Error(`Cannot find form control at index ${index}`);
}
}
@ -852,7 +851,7 @@ export class FormArray extends AbstractControl {
_checkAllValuesPresent(value: any): void {
this._forEachChild((control: AbstractControl, i: number) => {
if (value[i] === undefined) {
throw new BaseException(`Must supply a value for form control at index: ${i}.`);
throw new Error(`Must supply a value for form control at index: ${i}.`);
}
});
}