Skip to content

Commit 5a095bb

Browse files
refactor(di): rename ProviderError to BindingError
Closes angular#1428
1 parent de31aca commit 5a095bb

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

modules/angular2/di.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export {Inject, InjectPromise, InjectLazy, Injectable, Optional, DependencyAnnot
99
export {Injector} from './src/di/injector';
1010
export {Binding, ResolvedBinding, Dependency, bind} from './src/di/binding';
1111
export {Key, KeyRegistry} from './src/di/key';
12-
export {KeyMetadataError, NoProviderError, ProviderError, AsyncBindingError, CyclicDependencyError,
12+
export {KeyMetadataError, NoBindingError, AbstractBindingError, AsyncBindingError, CyclicDependencyError,
1313
InstantiationError, InvalidBindingError, NoAnnotationError} from './src/di/exceptions';
1414
export {OpaqueToken} from './src/di/opaque_token';

modules/angular2/docs/di/di.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ ctrlPromise.then((ctrl) {
316316
expect(ctrl).toBeAnInstanceOf(UserController);
317317
expect(ctrl.ul).toBeAnInstanceOf(UserList);
318318
});
319-
// No synchronous provider for UserList, results in a NoProviderError.
320-
expect(() => inj.get(UserController)).toThrow(new NoProviderError(...));
319+
// No synchronous provider for UserList, results in a NoBindingError.
320+
expect(() => inj.get(UserController)).toThrow(new NoBindingError(...));
321321
```
322322

323323

modules/angular2/src/core/compiler/element_injector.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {isPresent, isBlank, Type, int, BaseException} from 'angular2/src/facade/lang';
22
import {Math} from 'angular2/src/facade/math';
33
import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
4-
import {Injector, Key, Dependency, bind, Binding, ResolvedBinding, NoProviderError, ProviderError, CyclicDependencyError} from 'angular2/di';
4+
import {Injector, Key, Dependency, bind, Binding, ResolvedBinding, NoBindingError,
5+
AbstractBindingError, CyclicDependencyError} from 'angular2/di';
56
import {Parent, Ancestor} from 'angular2/src/core/annotations/visibility';
67
import {PropertySetter, Attribute, Query} from 'angular2/src/core/annotations/di';
78
import * as viewModule from 'angular2/src/core/compiler/view';
@@ -702,7 +703,7 @@ export class ElementInjector extends TreeNode {
702703
d8 = length > 8 ? this._getByDependency(deps[8], binding.key) : null;
703704
d9 = length > 9 ? this._getByDependency(deps[9], binding.key) : null;
704705
} catch(e) {
705-
if (e instanceof ProviderError) e.addKey(binding.key);
706+
if (e instanceof AbstractBindingError) e.addKey(binding.key);
706707
throw e;
707708
}
708709

modules/angular2/src/di/exceptions.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function constructResolvingPath(keys:List) {
3030
*
3131
* @exportedAs angular2/di_errors
3232
*/
33-
export class ProviderError extends Error {
33+
export class AbstractBindingError extends Error {
3434
keys:List;
3535
constructResolvingMessage:Function;
3636
message;
@@ -59,7 +59,7 @@ export class ProviderError extends Error {
5959
*
6060
* @exportedAs angular2/di_errors
6161
*/
62-
export class NoProviderError extends ProviderError {
62+
export class NoBindingError extends AbstractBindingError {
6363
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
6464
constructor(key) {
6565
super(key, function (keys:List) {
@@ -93,7 +93,7 @@ export class NoProviderError extends ProviderError {
9393
*
9494
* @exportedAs angular2/di_errors
9595
*/
96-
export class AsyncBindingError extends ProviderError {
96+
export class AsyncBindingError extends AbstractBindingError {
9797
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
9898
constructor(key) {
9999
super(key, function (keys:List) {
@@ -122,7 +122,7 @@ export class AsyncBindingError extends ProviderError {
122122
*
123123
* @exportedAs angular2/di_errors
124124
*/
125-
export class CyclicDependencyError extends ProviderError {
125+
export class CyclicDependencyError extends AbstractBindingError {
126126
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
127127
constructor(key) {
128128
super(key, function (keys:List) {
@@ -139,7 +139,7 @@ export class CyclicDependencyError extends ProviderError {
139139
*
140140
* @exportedAs angular2/di_errors
141141
*/
142-
export class InstantiationError extends ProviderError {
142+
export class InstantiationError extends AbstractBindingError {
143143
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
144144
constructor(originalException, key) {
145145
super(key, function (keys:List) {

modules/angular2/src/di/injector.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Map, List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
22
import {ResolvedBinding, Binding, BindingBuilder, bind} from './binding';
3-
import {ProviderError, NoProviderError, AsyncBindingError, CyclicDependencyError,
3+
import {AbstractBindingError, NoBindingError, AsyncBindingError, CyclicDependencyError,
44
InstantiationError, InvalidBindingError} from './exceptions';
55
import {FunctionWrapper, Type, isPresent, isBlank} from 'angular2/src/facade/lang';
66
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
@@ -205,7 +205,7 @@ export class Injector {
205205
if (optional) {
206206
return null;
207207
} else {
208-
throw new NoProviderError(key);
208+
throw new NoBindingError(key);
209209
}
210210
}
211211

@@ -215,7 +215,7 @@ export class Injector {
215215
return ListWrapper.map(binding.dependencies, getDependency);
216216
} catch (e) {
217217
this._clear(key);
218-
if (e instanceof ProviderError) e.addKey(key);
218+
if (e instanceof AbstractBindingError) e.addKey(key);
219219
throw e;
220220
}
221221
}
@@ -343,7 +343,7 @@ class _AsyncInjectorStrategy {
343343
}
344344

345345
_errorHandler(key:Key, e):Promise {
346-
if (e instanceof ProviderError) e.addKey(key);
346+
if (e instanceof AbstractBindingError) e.addKey(key);
347347
return PromiseWrapper.reject(e);
348348
}
349349

0 commit comments

Comments
 (0)