refactor(di): rename ProviderError to BindingError

Closes #1428
This commit is contained in:
Pawel Kozlowski 2015-04-17 19:18:29 +02:00
parent de31aca7a7
commit 5a095bb257
5 changed files with 15 additions and 14 deletions

View File

@ -9,6 +9,6 @@ export {Inject, InjectPromise, InjectLazy, Injectable, Optional, DependencyAnnot
export {Injector} from './src/di/injector';
export {Binding, ResolvedBinding, Dependency, bind} from './src/di/binding';
export {Key, KeyRegistry} from './src/di/key';
export {KeyMetadataError, NoProviderError, ProviderError, AsyncBindingError, CyclicDependencyError,
export {KeyMetadataError, NoBindingError, AbstractBindingError, AsyncBindingError, CyclicDependencyError,
InstantiationError, InvalidBindingError, NoAnnotationError} from './src/di/exceptions';
export {OpaqueToken} from './src/di/opaque_token';

View File

@ -316,8 +316,8 @@ ctrlPromise.then((ctrl) {
expect(ctrl).toBeAnInstanceOf(UserController);
expect(ctrl.ul).toBeAnInstanceOf(UserList);
});
// No synchronous provider for UserList, results in a NoProviderError.
expect(() => inj.get(UserController)).toThrow(new NoProviderError(...));
// No synchronous provider for UserList, results in a NoBindingError.
expect(() => inj.get(UserController)).toThrow(new NoBindingError(...));
```

View File

@ -1,7 +1,8 @@
import {isPresent, isBlank, Type, int, BaseException} from 'angular2/src/facade/lang';
import {Math} from 'angular2/src/facade/math';
import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
import {Injector, Key, Dependency, bind, Binding, ResolvedBinding, NoProviderError, ProviderError, CyclicDependencyError} from 'angular2/di';
import {Injector, Key, Dependency, bind, Binding, ResolvedBinding, NoBindingError,
AbstractBindingError, CyclicDependencyError} from 'angular2/di';
import {Parent, Ancestor} from 'angular2/src/core/annotations/visibility';
import {PropertySetter, Attribute, Query} from 'angular2/src/core/annotations/di';
import * as viewModule from 'angular2/src/core/compiler/view';
@ -702,7 +703,7 @@ export class ElementInjector extends TreeNode {
d8 = length > 8 ? this._getByDependency(deps[8], binding.key) : null;
d9 = length > 9 ? this._getByDependency(deps[9], binding.key) : null;
} catch(e) {
if (e instanceof ProviderError) e.addKey(binding.key);
if (e instanceof AbstractBindingError) e.addKey(binding.key);
throw e;
}

View File

@ -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) {

View File

@ -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);
}