fix(exceptions): NoAnnotationError message is not displayed
Closes #4215 Closes #4223
This commit is contained in:
parent
626e1cda5f
commit
eaa20f661a
@ -32,7 +32,6 @@ function constructResolvingPath(keys: any[]): string {
|
|||||||
* Base class for all errors arising from misconfigured bindings.
|
* Base class for all errors arising from misconfigured bindings.
|
||||||
*/
|
*/
|
||||||
export class AbstractBindingError extends BaseException {
|
export class AbstractBindingError extends BaseException {
|
||||||
name: string;
|
|
||||||
message: string;
|
message: string;
|
||||||
keys: Key[];
|
keys: Key[];
|
||||||
injectors: Injector[];
|
injectors: Injector[];
|
||||||
@ -99,7 +98,6 @@ export class CyclicDependencyError extends AbstractBindingError {
|
|||||||
* this object to be instantiated.
|
* this object to be instantiated.
|
||||||
*/
|
*/
|
||||||
export class InstantiationError extends WrappedException {
|
export class InstantiationError extends WrappedException {
|
||||||
name: string;
|
|
||||||
keys: Key[];
|
keys: Key[];
|
||||||
injectors: Injector[];
|
injectors: Injector[];
|
||||||
|
|
||||||
@ -129,14 +127,10 @@ export class InstantiationError extends WrappedException {
|
|||||||
* creation.
|
* creation.
|
||||||
*/
|
*/
|
||||||
export class InvalidBindingError extends BaseException {
|
export class InvalidBindingError extends BaseException {
|
||||||
message: string;
|
|
||||||
constructor(binding) {
|
constructor(binding) {
|
||||||
super();
|
super("Invalid binding - only instances of Binding and Type are allowed, got: " +
|
||||||
this.message = "Invalid binding - only instances of Binding and Type are allowed, got: " +
|
binding.toString());
|
||||||
binding.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string { return this.message; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,10 +140,11 @@ export class InvalidBindingError extends BaseException {
|
|||||||
* need to be injected into the constructor.
|
* need to be injected into the constructor.
|
||||||
*/
|
*/
|
||||||
export class NoAnnotationError extends BaseException {
|
export class NoAnnotationError extends BaseException {
|
||||||
name: string;
|
|
||||||
message: string;
|
|
||||||
constructor(typeOrFunc, params: any[][]) {
|
constructor(typeOrFunc, params: any[][]) {
|
||||||
super();
|
super(NoAnnotationError._genMessage(typeOrFunc, params));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static _genMessage(typeOrFunc, params: any[][]) {
|
||||||
var signature = [];
|
var signature = [];
|
||||||
for (var i = 0, ii = params.length; i < ii; i++) {
|
for (var i = 0, ii = params.length; i < ii; i++) {
|
||||||
var parameter = params[i];
|
var parameter = params[i];
|
||||||
@ -159,37 +154,24 @@ export class NoAnnotationError extends BaseException {
|
|||||||
signature.push(ListWrapper.map(parameter, stringify).join(' '));
|
signature.push(ListWrapper.map(parameter, stringify).join(' '));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.message = "Cannot resolve all parameters for " + stringify(typeOrFunc) + "(" +
|
return "Cannot resolve all parameters for " + stringify(typeOrFunc) + "(" +
|
||||||
signature.join(', ') + "). " +
|
signature.join(', ') + "). " + 'Make sure they all have valid type or annotations.';
|
||||||
'Make sure they all have valid type or annotations.';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string { return this.message; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when getting an object by index.
|
* Thrown when getting an object by index.
|
||||||
*/
|
*/
|
||||||
export class OutOfBoundsError extends BaseException {
|
export class OutOfBoundsError extends BaseException {
|
||||||
message: string;
|
constructor(index) { super(`Index ${index} is out-of-bounds.`); }
|
||||||
constructor(index) {
|
|
||||||
super();
|
|
||||||
this.message = `Index ${index} is out-of-bounds.`;
|
|
||||||
}
|
|
||||||
|
|
||||||
toString(): string { return this.message; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when a multi binding and a regular binding are bound to the same token.
|
* Thrown when a multi binding and a regular binding are bound to the same token.
|
||||||
*/
|
*/
|
||||||
export class MixingMultiBindingsWithRegularBindings extends BaseException {
|
export class MixingMultiBindingsWithRegularBindings extends BaseException {
|
||||||
message: string;
|
|
||||||
constructor(binding1, binding2) {
|
constructor(binding1, binding2) {
|
||||||
super();
|
super("Cannot mix multi bindings and regular bindings, got: " + binding1.toString() + " " +
|
||||||
this.message = "Cannot mix multi bindings and regular bindings, got: " + binding1.toString() +
|
binding2.toString());
|
||||||
" " + binding2.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string { return this.message; }
|
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ export {ExceptionHandler} from './exception_handler';
|
|||||||
|
|
||||||
export class BaseException extends Error {
|
export class BaseException extends Error {
|
||||||
public stack: any;
|
public stack: any;
|
||||||
constructor(public message?: string) {
|
constructor(public message: string = "--") {
|
||||||
super(message);
|
super(message);
|
||||||
this.stack = (<any>new Error(message)).stack;
|
this.stack = (<any>new Error(message)).stack;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user