diff --git a/modules/di/src/exceptions.js b/modules/di/src/exceptions.js index cebf1f1d11..403e716a05 100644 --- a/modules/di/src/exceptions.js +++ b/modules/di/src/exceptions.js @@ -12,13 +12,7 @@ function constructResolvingPath(keys: List) { } } -class DIError extends Error { - toString() { - return this.message; - } -} - -export class ProviderError extends DIError { +export class ProviderError extends Error { constructor(key:Key, constructResolvingMessage:Function){ this.keys = [key]; this.constructResolvingMessage = constructResolvingMessage; @@ -29,6 +23,10 @@ export class ProviderError extends DIError { ListWrapper.push(this.keys, key); this.message = this.constructResolvingMessage(this.keys); } + + toString() { + return this.message; + } } export class NoProviderError extends ProviderError { @@ -68,14 +66,22 @@ export class InstantiationError extends ProviderError { } } -export class InvalidBindingError extends DIError { +export class InvalidBindingError extends Error { constructor(binding){ this.message = `Invalid binding ${binding}`; } + + toString() { + return this.message; + } } -export class NoAnnotationError extends DIError { +export class NoAnnotationError extends Error { constructor(type){ this.message = `Cannot resolve all parameters for ${stringify(type)}`; } + + toString() { + return this.message; + } } \ No newline at end of file