feat(di): changed InstantiationError to print the original stack

This commit is contained in:
vsavkin
2015-06-27 20:01:05 -07:00
parent 56245c6aa2
commit eb0fd7967c
3 changed files with 15 additions and 16 deletions

View File

@ -36,8 +36,8 @@ export class AbstractBindingError extends BaseException {
keys: List<any>;
constructResolvingMessage: Function;
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(key, constructResolvingMessage: Function) {
super();
constructor(key, constructResolvingMessage: Function, originalException?, originalStack?) {
super(null, originalException, originalStack);
this.keys = [key];
this.constructResolvingMessage = constructResolvingMessage;
this.message = this.constructResolvingMessage(this.keys);
@ -138,19 +138,18 @@ export class CyclicDependencyError extends AbstractBindingError {
* @exportedAs angular2/di_errors
*/
export class InstantiationError extends AbstractBindingError {
cause;
causeKey;
stack;
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(cause, stack, key) {
constructor(originalException, originalStack, key) {
super(key, function(keys: List<any>) {
var first = stringify(ListWrapper.first(keys).token);
return `Error during instantiation of ${first}!${constructResolvingPath(keys)}. ORIGINAL ERROR: ${cause}`;
});
this.cause = cause;
return `Error during instantiation of ${first}!${constructResolvingPath(keys)}.` +
` ORIGINAL ERROR: ${originalException}` +
`\n\n ORIGINAL STACK: ${originalStack}`;
}, originalException, originalStack);
this.causeKey = key;
this.stack = stack;
}
}