make-error-cause
Advanced tools
Comparing version 1.2.1 to 1.2.2
import makeError = require('make-error'); | ||
declare function makeErrorCause(value: string | Function): makeErrorCause.Constructor<makeErrorCause.BaseError>; | ||
declare function makeErrorCause<T extends Error>(value: string | Function, _super: { | ||
new (...args: any[]): T; | ||
}): makeErrorCause.Constructor<T>; | ||
declare namespace makeErrorCause { | ||
@@ -4,0 +7,0 @@ class BaseError extends makeError.BaseError { |
@@ -6,10 +6,18 @@ "use strict"; | ||
var TestError = makeErrorCause('TestError'); | ||
var SubTestError = makeErrorCause('SubTestError', TestError); | ||
t.test('render the cause', function (t) { | ||
var cause = new Error('boom!'); | ||
var error = new TestError('something bad', cause); | ||
var again = new TestError('more bad', error); | ||
var again = new SubTestError('more bad', error); | ||
t.equal(error.cause, cause); | ||
t.equal(error.toString(), 'TestError: something bad\nCaused by: Error: boom!'); | ||
t.ok(error instanceof Error); | ||
t.ok(error instanceof makeErrorCause.BaseError); | ||
t.ok(error instanceof TestError); | ||
t.equal(again.cause, error); | ||
t.equal(again.toString(), 'TestError: more bad\nCaused by: TestError: something bad\nCaused by: Error: boom!'); | ||
t.equal(again.toString(), 'SubTestError: more bad\nCaused by: TestError: something bad\nCaused by: Error: boom!'); | ||
t.ok(again instanceof Error); | ||
t.ok(again instanceof makeErrorCause.BaseError); | ||
t.ok(again instanceof TestError); | ||
t.ok(again instanceof SubTestError); | ||
t.end(); | ||
@@ -16,0 +24,0 @@ }); |
{ | ||
"name": "make-error-cause", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Make your own nested error types!", | ||
@@ -41,9 +41,9 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"blue-tape": "^0.2.0", | ||
"blue-tape": "^1.0.0", | ||
"istanbul": "1.0.0-alpha.2", | ||
"tap-spec": "^4.1.1", | ||
"ts-node": "^0.9.0", | ||
"ts-node": "^1.1.0", | ||
"tslint": "^3.10.2", | ||
"tslint-config-standard": "^1.0.0", | ||
"typescript": "^1.7.3", | ||
"typescript": "^2.0.3", | ||
"typings": "^1.3.1" | ||
@@ -50,0 +50,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
10784
9
69
0
55