Skip to content

Commit

Permalink
[BUGFIX release] Fix Ember.Error inheritance
Browse files Browse the repository at this point in the history
As pointed out by @schuay #15516 our error constructor essentially calls super twice. The reasons seems to have been an error in ExtendableBuiltin constructor, which did not return its `apply` call. I can’t seem to find the issue ExtendBuiltin is working around. I suspect we can simply remove it
  • Loading branch information
stefanpenner committed Jul 17, 2017
1 parent cfabfc3 commit 868cf19
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions packages/ember-debug/lib/error.js
@@ -1,14 +1,3 @@

function ExtendBuiltin(klass) {
function ExtendableBuiltin() {
klass.apply(this, arguments);
}

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

/**
A subclass of the JavaScript Error object for use in Ember.
Expand All @@ -18,15 +7,12 @@ function ExtendBuiltin(klass) {
@constructor
@public
*/
export default class EmberError extends ExtendBuiltin(Error) {
constructor(message) {
super();

if (!(this instanceof EmberError)) {
return new EmberError(message);
}
export default EmberError;
function EmberError(message, code) {
if (this instanceof EmberError) {
let error = Error.call(this, message, code);

let error = Error.call(this, message);
this.stack = error.stack;
this.description = error.description;
this.fileName = error.fileName;
Expand All @@ -35,5 +21,9 @@ export default class EmberError extends ExtendBuiltin(Error) {
this.name = error.name;
this.number = error.number;
this.code = error.code;
} else {
return new EmberError(message, code);
}
}

EmberError.prototype = Object.create(Error.prototype);

0 comments on commit 868cf19

Please sign in to comment.