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:

committed by
Victor Berchet

parent
86ba072758
commit
7c07bfff97
@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
import {ChangeDetectorRef, ComponentRef, DebugElement, ElementRef, NgZone, getDebugNode} from '../index';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {scheduleMicroTask} from '../src/facade/lang';
|
||||
|
||||
import {tick} from './fake_async';
|
||||
@ -146,7 +145,7 @@ export class ComponentFixture<T> {
|
||||
*/
|
||||
autoDetectChanges(autoDetect: boolean = true) {
|
||||
if (this.ngZone == null) {
|
||||
throw new BaseException('Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set');
|
||||
throw new Error('Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set');
|
||||
}
|
||||
this._autoDetect = autoDetect;
|
||||
this.detectChanges();
|
||||
|
@ -6,7 +6,6 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {BaseException} from '../index';
|
||||
|
||||
|
||||
const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec'];
|
||||
@ -53,13 +52,13 @@ export function fakeAsync(fn: Function): (...args: any[]) => any {
|
||||
return function(...args: any[]) {
|
||||
const proxyZoneSpec = ProxyZoneSpec.assertPresent();
|
||||
if (_inFakeAsyncCall) {
|
||||
throw new BaseException('fakeAsync() calls can not be nested');
|
||||
throw new Error('fakeAsync() calls can not be nested');
|
||||
}
|
||||
_inFakeAsyncCall = true;
|
||||
try {
|
||||
if (!_fakeAsyncTestZoneSpec) {
|
||||
if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) {
|
||||
throw new BaseException('fakeAsync() calls can not be nested');
|
||||
throw new Error('fakeAsync() calls can not be nested');
|
||||
}
|
||||
|
||||
_fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec();
|
||||
@ -76,13 +75,13 @@ export function fakeAsync(fn: Function): (...args: any[]) => any {
|
||||
}
|
||||
|
||||
if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) {
|
||||
throw new BaseException(
|
||||
throw new Error(
|
||||
`${_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length} ` +
|
||||
`periodic timer(s) still in the queue.`);
|
||||
}
|
||||
|
||||
if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) {
|
||||
throw new BaseException(
|
||||
throw new Error(
|
||||
`${_fakeAsyncTestZoneSpec.pendingTimers.length} timer(s) still in the queue.`);
|
||||
}
|
||||
return res;
|
||||
|
@ -6,9 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {CompilerOptions, ComponentMetadataType, ComponentStillLoadingError, DirectiveMetadataType, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleMetadataType, NgModuleRef, NgZone, OpaqueToken, PipeMetadataType, PlatformRef, Provider, SchemaMetadata} from '../index';
|
||||
import {CompilerOptions, ComponentMetadataType, DirectiveMetadataType, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleMetadataType, NgModuleRef, NgZone, OpaqueToken, PipeMetadataType, PlatformRef, Provider, SchemaMetadata} from '../index';
|
||||
import {ListWrapper} from '../src/facade/collection';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {FunctionWrapper, stringify} from '../src/facade/lang';
|
||||
import {Type} from '../src/type';
|
||||
|
||||
@ -173,7 +172,7 @@ export class TestBed implements Injector {
|
||||
*/
|
||||
initTestEnvironment(ngModule: Type<any>, platform: PlatformRef) {
|
||||
if (this.platform || this.ngModule) {
|
||||
throw new BaseException('Cannot set base providers because it has already been called');
|
||||
throw new Error('Cannot set base providers because it has already been called');
|
||||
}
|
||||
this.platform = platform;
|
||||
this.ngModule = ngModule;
|
||||
@ -256,7 +255,7 @@ export class TestBed implements Injector {
|
||||
this._moduleWithComponentFactories =
|
||||
this._compiler.compileModuleAndAllComponentsSync(moduleType);
|
||||
} catch (e) {
|
||||
if (e instanceof ComponentStillLoadingError) {
|
||||
if (e.compType) {
|
||||
throw new Error(
|
||||
`This test module uses the component ${stringify(e.compType)} which is using a "templateUrl", but they were never compiled. ` +
|
||||
`Please call "TestBed.compileComponents" before your test.`);
|
||||
@ -296,7 +295,7 @@ export class TestBed implements Injector {
|
||||
|
||||
private _assertNotInstantiated(methodName: string, methodDescription: string) {
|
||||
if (this._instantiated) {
|
||||
throw new BaseException(
|
||||
throw new Error(
|
||||
`Cannot ${methodDescription} when the test module has already been instantiated. ` +
|
||||
`Make sure you are not using \`inject\` before \`${methodName}\`.`);
|
||||
}
|
||||
@ -344,7 +343,7 @@ export class TestBed implements Injector {
|
||||
const componentFactory = this._moduleWithComponentFactories.componentFactories.find(
|
||||
(compFactory) => compFactory.componentType === component);
|
||||
if (!componentFactory) {
|
||||
throw new BaseException(
|
||||
throw new Error(
|
||||
`Cannot create the component ${stringify(component)} as it was not imported into the testing module!`);
|
||||
}
|
||||
const noNgZone = this.get(ComponentFixtureNoNgZone, false);
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {Compiler, CompilerOptions, ComponentMetadataType, DirectiveMetadataType, Injector, NgModuleMetadataType, PipeMetadataType} from '../index';
|
||||
import {unimplemented} from '../src/facade/exceptions';
|
||||
import {unimplemented} from '../src/facade/errors';
|
||||
import {Type} from '../src/type';
|
||||
import {MetadataOverride} from './metadata_override';
|
||||
|
||||
|
Reference in New Issue
Block a user