base-error
Advanced tools
Comparing version 1.0.1 to 1.0.2
38
index.js
@@ -1,15 +0,33 @@ | ||
'use strict'; | ||
(function (root) { | ||
'use strict'; | ||
var util = require("util"); | ||
function BaseError (message) { | ||
var err = new Error(message); | ||
function BaseError (message) { | ||
Error.call(this); | ||
Error.captureStackTrace(this, this.constructor); | ||
this.stack = err.stack; | ||
this.message = message; | ||
} | ||
this.className = this.constructor.name | ||
this.message = message; | ||
} | ||
BaseError.prototype = new Error(); | ||
BaseError.prototype.name = 'BaseError'; | ||
util.inherits(BaseError, Error); | ||
module.exports = BaseError; | ||
//Exports | ||
//AMD | ||
if (typeof define !== 'undefined' && define.amd) { | ||
define([], function () { | ||
return BaseError; | ||
}); | ||
} | ||
//CommonJS | ||
else if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = BaseError; | ||
} | ||
//Script tag | ||
else { | ||
root.BaseError = BaseError; | ||
} | ||
} (this)); |
{ | ||
"name": "base-error", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Base Error", | ||
@@ -15,3 +15,3 @@ "author": { | ||
"keywords": [ | ||
"Error", | ||
"error", | ||
"extend" | ||
@@ -35,7 +35,7 @@ ], | ||
"devDependencies": { | ||
"grunt": "~0.4.2", | ||
"grunt-cli": "~0.1.11", | ||
"grunt": "~0.4.4", | ||
"grunt-cli": "~0.1.13", | ||
"grunt-env": "~0.4.1", | ||
"grunt-mocha-test": "~0.8.1", | ||
"should": "~2.1.1" | ||
"grunt-mocha-test": "~0.10.2", | ||
"should": "~3.3.1" | ||
}, | ||
@@ -42,0 +42,0 @@ "bugs": { |
@@ -7,2 +7,5 @@ Base Error | ||
You can use this library as AMD, CommonJS or root library in your [Webpack](http://webpack.github.io/) or [RequireJS](http://requirejs.org/) module bundler. | ||
Works in the browser, in [NodeJS](http://nodejs.org/), [Bower](http://bower.io/) and with [Browserify](http://browserify.org/). | ||
# Example | ||
@@ -9,0 +12,0 @@ var BaseError = require('base-error'); |
@@ -21,9 +21,9 @@ 'use strict'; | ||
error.should.have.property('className'); | ||
error.className.should.equal('BaseError'); | ||
error.should.have.property('name'); | ||
error.name.should.equal('BaseError'); | ||
(error instanceof Error).should.equal(true); | ||
(error instanceof BaseError).should.equal(true); | ||
done(); | ||
@@ -30,0 +30,0 @@ }); |
4690
7
87
16