10
modules/angular2/src/di/exceptions.js
vendored
10
modules/angular2/src/di/exceptions.js
vendored
@ -30,7 +30,7 @@ function constructResolvingPath(keys:List) {
|
||||
*
|
||||
* @exportedAs angular2/di_errors
|
||||
*/
|
||||
export class ProviderError extends Error {
|
||||
export class AbstractBindingError extends Error {
|
||||
keys:List;
|
||||
constructResolvingMessage:Function;
|
||||
message;
|
||||
@ -59,7 +59,7 @@ export class ProviderError extends Error {
|
||||
*
|
||||
* @exportedAs angular2/di_errors
|
||||
*/
|
||||
export class NoProviderError extends ProviderError {
|
||||
export class NoBindingError extends AbstractBindingError {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
constructor(key) {
|
||||
super(key, function (keys:List) {
|
||||
@ -93,7 +93,7 @@ export class NoProviderError extends ProviderError {
|
||||
*
|
||||
* @exportedAs angular2/di_errors
|
||||
*/
|
||||
export class AsyncBindingError extends ProviderError {
|
||||
export class AsyncBindingError extends AbstractBindingError {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
constructor(key) {
|
||||
super(key, function (keys:List) {
|
||||
@ -122,7 +122,7 @@ export class AsyncBindingError extends ProviderError {
|
||||
*
|
||||
* @exportedAs angular2/di_errors
|
||||
*/
|
||||
export class CyclicDependencyError extends ProviderError {
|
||||
export class CyclicDependencyError extends AbstractBindingError {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
constructor(key) {
|
||||
super(key, function (keys:List) {
|
||||
@ -139,7 +139,7 @@ export class CyclicDependencyError extends ProviderError {
|
||||
*
|
||||
* @exportedAs angular2/di_errors
|
||||
*/
|
||||
export class InstantiationError extends ProviderError {
|
||||
export class InstantiationError extends AbstractBindingError {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
constructor(originalException, key) {
|
||||
super(key, function (keys:List) {
|
||||
|
8
modules/angular2/src/di/injector.js
vendored
8
modules/angular2/src/di/injector.js
vendored
@ -1,6 +1,6 @@
|
||||
import {Map, List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {ResolvedBinding, Binding, BindingBuilder, bind} from './binding';
|
||||
import {ProviderError, NoProviderError, AsyncBindingError, CyclicDependencyError,
|
||||
import {AbstractBindingError, NoBindingError, AsyncBindingError, CyclicDependencyError,
|
||||
InstantiationError, InvalidBindingError} from './exceptions';
|
||||
import {FunctionWrapper, Type, isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
|
||||
@ -205,7 +205,7 @@ export class Injector {
|
||||
if (optional) {
|
||||
return null;
|
||||
} else {
|
||||
throw new NoProviderError(key);
|
||||
throw new NoBindingError(key);
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ export class Injector {
|
||||
return ListWrapper.map(binding.dependencies, getDependency);
|
||||
} catch (e) {
|
||||
this._clear(key);
|
||||
if (e instanceof ProviderError) e.addKey(key);
|
||||
if (e instanceof AbstractBindingError) e.addKey(key);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@ -343,7 +343,7 @@ class _AsyncInjectorStrategy {
|
||||
}
|
||||
|
||||
_errorHandler(key:Key, e):Promise {
|
||||
if (e instanceof ProviderError) e.addKey(key);
|
||||
if (e instanceof AbstractBindingError) e.addKey(key);
|
||||
return PromiseWrapper.reject(e);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user