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 {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');