Skip to content

Commit

Permalink
fix(di/exceptions): initialize Error superclass with message
Browse files Browse the repository at this point in the history
For subclasses of Error, initializing classes without providing a 
message to super() would cause any messages to be suppressed from
logged errors. This fix provides an initial message to super().

Fixes angular#2570
  • Loading branch information
jeffbcross committed Jun 17, 2015
1 parent b2c6694 commit 58c38f9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/angular2/src/di/exceptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class AbstractBindingError extends BaseException {
constructResolvingMessage: Function;
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(key, constructResolvingMessage: Function) {
super();
super(constructResolvingMessage([key]));
this.keys = [key];
this.constructResolvingMessage = constructResolvingMessage;
this.message = this.constructResolvingMessage(this.keys);
Expand Down
3 changes: 3 additions & 0 deletions modules/angular2/test/di/exceptions_spec.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library angular2.test.di.exceptions_spec;
// Not implemented
main() {}
23 changes: 23 additions & 0 deletions modules/angular2/test/di/exceptions_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
AsyncTestCompleter,
beforeEach,
ddescribe,
describe,
expect,
iit,
inject,
it,
xit,
} from 'angular2/test_lib';
import {AbstractBindingError} from 'angular2/di';

export function main() {
describe('exceptions', () => {
it('should have the proper message when thrown', () => {
try {
throw new AbstractBindingError('foo', () => { return 'message'; });
} catch (e) {
expect(e.stack.split('\n')[0]).toBe('Error: message');
}
});
}

0 comments on commit 58c38f9

Please sign in to comment.