Skip to content

Commit

Permalink
Use native Error instead of custom Error subclass.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Nov 19, 2018
1 parent 620f97c commit a5fb2f3
Showing 1 changed file with 1 addition and 42 deletions.
43 changes: 1 addition & 42 deletions packages/@ember/error/index.ts
@@ -1,46 +1,5 @@
/**
@module @ember/error
*/
function ExtendBuiltin(klass: any): typeof Error {
function ExtendableBuiltin(this: any) {
klass.apply(this, arguments);
}

ExtendableBuiltin.prototype = Object.create(klass.prototype);
ExtendableBuiltin.prototype.constructor = ExtendableBuiltin;
return ExtendableBuiltin as typeof Error;
}

/**
A subclass of the JavaScript Error object for use in Ember.
@class EmberError
@extends Error
@constructor
@public
*/
export default class EmberError extends ExtendBuiltin(Error) {
description: string;
fileName: string;
lineNumber: number;
number: number;
code: string;

constructor(message: string) {
super();

if (!(this instanceof EmberError)) {
return new EmberError(message);
}

let error = Error.call(this, message);
this.stack = error.stack;
this.description = error.description;
this.fileName = error.fileName;
this.lineNumber = error.lineNumber;
this.message = error.message;
this.name = error.name;
this.number = error.number;
this.code = error.code;
}
}
export default Error;

0 comments on commit a5fb2f3

Please sign in to comment.