diff --git a/modules/angular2/src/di/exceptions.js b/modules/angular2/src/di/exceptions.js index 3d99ea2e89..c0aea9a062 100644 --- a/modules/angular2/src/di/exceptions.js +++ b/modules/angular2/src/di/exceptions.js @@ -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 { diff --git a/modules/angular2/src/di/injector.js b/modules/angular2/src/di/injector.js index 3dc128eebf..127e2e8bd3 100644 --- a/modules/angular2/src/di/injector.js +++ b/modules/angular2/src/di/injector.js @@ -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); } diff --git a/modules/angular2/test/di/injector_spec.js b/modules/angular2/test/di/injector_spec.js index 8bd11f2a1e..cb2aa85375 100644 --- a/modules/angular2/test/di/injector_spec.js +++ b/modules/angular2/test/di/injector_spec.js @@ -205,8 +205,11 @@ export function main() { }); it('should throw when given invalid bindings', function () { - expect(() => Injector.resolveAndCreate(["blah"])).toThrowError('Invalid binding blah'); - expect(() => Injector.resolveAndCreate([bind("blah")])).toThrowError('Invalid binding blah'); + expect(() => Injector.resolveAndCreate(["blah"])) + .toThrowError('Invalid binding - only instances of Binding and Type are allowed, got: blah'); + expect(() => Injector.resolveAndCreate([bind("blah")])) + .toThrowError('Invalid binding - only instances of Binding and Type are allowed, ' + + 'got: BindingBuilder with blah token'); }); it('should provide itself', function () {