Skip to content

Instantly share code, notes, and snippets.

@japboy
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save japboy/5b1feeb72126ee6b885c to your computer and use it in GitHub Desktop.
Save japboy/5b1feeb72126ee6b885c to your computer and use it in GitHub Desktop.
My subclass for Error class
'use strict'
global = global or window
###
Subclass for Error
@class
@extends global.Error
@see http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript
@see https://gist.github.com/xdissent/d20bbdd57ca16b3d86b5
###
class exports.Error
constructor: (message) ->
@name = @constructor.name
@message = message
@stack = (new global.Error).stack
@:: = new global.Error
@::constructor = @
'use strict';
let global = global || window;
/**
* Subclass for Error
* @class
* @extends global.Error
* @see http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript
* @see https://gist.github.com/xdissent/d20bbdd57ca16b3d86b5
*/
export class Error extends global.Error {
constructor (message) {
this.name = this.constructor.name;
this.message = message;
this.stack = (new global.Error).stack
}
this.prototype = new global.Error;
this.prototype.constructor = this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment