fix(di): improve error messages for invalid bindings
Fixes #1515 Closes #1573
This commit is contained in:

committed by
Misko Hevery

parent
c0f3778dda
commit
ee1b574baf
2
modules/angular2/src/di/exceptions.js
vendored
2
modules/angular2/src/di/exceptions.js
vendored
@ -163,7 +163,7 @@ export class InvalidBindingError extends Error {
|
||||
message:string;
|
||||
constructor(binding) {
|
||||
super();
|
||||
this.message = `Invalid binding ${binding}`;
|
||||
this.message = `Invalid binding - only instances of Binding and Type are allowed, got: ${binding}`;
|
||||
}
|
||||
|
||||
toString():string {
|
||||
|
2
modules/angular2/src/di/injector.js
vendored
2
modules/angular2/src/di/injector.js
vendored
@ -379,7 +379,7 @@ function _resolveBindings(bindings:List): List {
|
||||
} else if (unresolved instanceof List) {
|
||||
resolved = _resolveBindings(unresolved);
|
||||
} else if (unresolved instanceof BindingBuilder) {
|
||||
throw new InvalidBindingError(unresolved.token);
|
||||
throw new InvalidBindingError('BindingBuilder with ' + unresolved.token + ' token');
|
||||
} else {
|
||||
throw new InvalidBindingError(unresolved);
|
||||
}
|
||||
|
Reference in New Issue
Block a user