X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 11 additions & 29 deletions modules/angular2/src/core/di/exceptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function constructResolvingPath(keys: any[]): string {
* Base class for all errors arising from misconfigured bindings.
*/
export class AbstractBindingError extends BaseException {
name: string;
message: string;
keys: Key[];
injectors: Injector[];
Expand Down Expand Up @@ -99,7 +98,6 @@ export class CyclicDependencyError extends AbstractBindingError {
* this object to be instantiated.
*/
export class InstantiationError extends WrappedException {
name: string;
keys: Key[];
injectors: Injector[];

Expand Down Expand Up @@ -129,14 +127,10 @@ export class InstantiationError extends WrappedException {
* creation.
*/
export class InvalidBindingError extends BaseException {
message: string;
constructor(binding) {
super();
this.message = "Invalid binding - only instances of Binding and Type are allowed, got: " +
binding.toString();
super("Invalid binding - only instances of Binding and Type are allowed, got: " +
binding.toString());
}

toString(): string { return this.message; }
}

/**
Expand All @@ -146,10 +140,11 @@ export class InvalidBindingError extends BaseException {
* need to be injected into the constructor.
*/
export class NoAnnotationError extends BaseException {
name: string;
message: string;
constructor(typeOrFunc, params: any[][]) {
super();
super(NoAnnotationError._genMessage(typeOrFunc, params));
}

private static _genMessage(typeOrFunc, params: any[][]) {
var signature = [];
for (var i = 0, ii = params.length; i < ii; i++) {
var parameter = params[i];
Expand All @@ -159,37 +154,24 @@ export class NoAnnotationError extends BaseException {
signature.push(ListWrapper.map(parameter, stringify).join(' '));
}
}
this.message = "Cannot resolve all parameters for " + stringify(typeOrFunc) + "(" +
signature.join(', ') + "). " +
'Make sure they all have valid type or annotations.';
return "Cannot resolve all parameters for " + stringify(typeOrFunc) + "(" +
signature.join(', ') + "). " + 'Make sure they all have valid type or annotations.';
}

toString(): string { return this.message; }
}

/**
* Thrown when getting an object by index.
*/
export class OutOfBoundsError extends BaseException {
message: string;
constructor(index) {
super();
this.message = `Index ${index} is out-of-bounds.`;
}

toString(): string { return this.message; }
constructor(index) { super(`Index ${index} is out-of-bounds.`); }
}

/**
* Thrown when a multi binding and a regular binding are bound to the same token.
*/
export class MixingMultiBindingsWithRegularBindings extends BaseException {
message: string;
constructor(binding1, binding2) {
super();
this.message = "Cannot mix multi bindings and regular bindings, got: " + binding1.toString() +
" " + binding2.toString();
super("Cannot mix multi bindings and regular bindings, got: " + binding1.toString() + " " +
binding2.toString());
}

toString(): string { return this.message; }
}
2 changes: 1 addition & 1 deletion modules/angular2/src/core/facade/exceptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export {ExceptionHandler} from './exception_handler';

export class BaseException extends Error {
public stack: any;
constructor(public message?: string) {
constructor(public message: string = "--") {
super(message);
this.stack = (<any>new Error(message)).stack;
}
Expand Down
X Tutup