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
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ExceptionHandler, Inject, Input, NgModule, OnDestroy, PLATFORM_INITIALIZER, Pipe, Provider, createPlatformFactory} from '@angular/core';
|
||||
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ErrorHandler, Inject, Input, NgModule, OnDestroy, PLATFORM_INITIALIZER, Pipe, Provider, createPlatformFactory} from '@angular/core';
|
||||
import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref';
|
||||
import {Console} from '@angular/core/src/console';
|
||||
import {ComponentRef} from '@angular/core/src/linker/component_factory';
|
||||
@ -94,12 +94,9 @@ class HelloCmpUsingPlatformDirectiveAndPipe {
|
||||
class HelloCmpUsingCustomElement {
|
||||
}
|
||||
|
||||
class _ArrayLogger {
|
||||
class MockConsole {
|
||||
res: any[] = [];
|
||||
log(s: any): void { this.res.push(s); }
|
||||
logError(s: any): void { this.res.push(s); }
|
||||
logGroup(s: any): void { this.res.push(s); }
|
||||
logGroupEnd(){};
|
||||
error(s: any): void { this.res.push(s); }
|
||||
}
|
||||
|
||||
|
||||
@ -160,10 +157,11 @@ export function main() {
|
||||
|
||||
it('should throw if no element is found',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var logger = new _ArrayLogger();
|
||||
var exceptionHandler = new ExceptionHandler(logger, false);
|
||||
var logger = new MockConsole();
|
||||
var errorHandler = new ErrorHandler(false);
|
||||
errorHandler._console = logger as any;
|
||||
bootstrap(HelloRootCmp, [
|
||||
{provide: ExceptionHandler, useValue: exceptionHandler}
|
||||
{provide: ErrorHandler, useValue: errorHandler}
|
||||
]).then(null, (reason) => {
|
||||
expect(reason.message).toContain('The selector "hello-app" did not match any elements');
|
||||
async.done();
|
||||
@ -174,11 +172,12 @@ export function main() {
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
it('should forward the error to promise when bootstrap fails',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var logger = new _ArrayLogger();
|
||||
var exceptionHandler = new ExceptionHandler(logger, false);
|
||||
var logger = new MockConsole();
|
||||
var errorHandler = new ErrorHandler(false);
|
||||
errorHandler._console = logger as any;
|
||||
|
||||
var refPromise =
|
||||
bootstrap(HelloRootCmp, [{provide: ExceptionHandler, useValue: exceptionHandler}]);
|
||||
bootstrap(HelloRootCmp, [{provide: ErrorHandler, useValue: errorHandler}]);
|
||||
refPromise.then(null, (reason: any) => {
|
||||
expect(reason.message)
|
||||
.toContain('The selector "hello-app" did not match any elements');
|
||||
@ -188,11 +187,12 @@ export function main() {
|
||||
|
||||
it('should invoke the default exception handler when bootstrap fails',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var logger = new _ArrayLogger();
|
||||
var exceptionHandler = new ExceptionHandler(logger, false);
|
||||
var logger = new MockConsole();
|
||||
var errorHandler = new ErrorHandler(false);
|
||||
errorHandler._console = logger as any;
|
||||
|
||||
var refPromise =
|
||||
bootstrap(HelloRootCmp, [{provide: ExceptionHandler, useValue: exceptionHandler}]);
|
||||
bootstrap(HelloRootCmp, [{provide: ErrorHandler, useValue: errorHandler}]);
|
||||
refPromise.then(null, (reason) => {
|
||||
expect(logger.res.join(''))
|
||||
.toContain('The selector "hello-app" did not match any elements');
|
||||
|
@ -11,7 +11,6 @@ import {NgZone} from '@angular/core/src/zone/ng_zone';
|
||||
import {ClientMessageBroker, ClientMessageBrokerFactory_, UiArguments} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
|
||||
import {MessageBus, MessageBusSink, MessageBusSource} from '@angular/platform-browser/src/web_workers/shared/message_bus';
|
||||
import {ListWrapper, StringMapWrapper} from '../../../src/facade/collection';
|
||||
import {BaseException} from '../../../src/facade/exceptions';
|
||||
import {isPresent} from '../../../src/facade/lang';
|
||||
import {SpyMessageBroker} from '../worker/spies';
|
||||
|
||||
@ -89,7 +88,7 @@ export class MockMessageBusSource implements MessageBusSource {
|
||||
|
||||
from(channel: string): MockEventEmitter<any> {
|
||||
if (!StringMapWrapper.contains(this._channels, channel)) {
|
||||
throw new BaseException(`${channel} is not set up. Did you forget to call initChannel?`);
|
||||
throw new Error(`${channel} is not set up. Did you forget to call initChannel?`);
|
||||
}
|
||||
return this._channels[channel];
|
||||
}
|
||||
|
Reference in New Issue
Block a user