Socket
Socket
Sign inDemoInstall

errno

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

errno - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

4

custom.js

@@ -18,3 +18,3 @@ var prr = require('prr')

if (Error.captureStackTrace)
Error.captureStackTrace(this, arguments.callee)
Error.captureStackTrace(this, this.constructor)
init.call(this, 'CustomError', message, cause)

@@ -41,3 +41,3 @@ }

if (Error.captureStackTrace)
Error.captureStackTrace(this, arguments.callee)
Error.captureStackTrace(this, err)
}

@@ -44,0 +44,0 @@ err.prototype = !!proto ? new proto() : new CustomError()

@@ -12,3 +12,3 @@ {

],
"version": "0.1.5",
"version": "0.1.6",
"main": "errno.js",

@@ -22,2 +22,4 @@ "dependencies": {

"devDependencies": {
"error-stack-parser": "^2.0.1",
"inherits": "^2.0.3",
"tape": "~4.8.0"

@@ -31,4 +33,4 @@ },

"scripts": {
"test": "tape test.js"
"test": "node --use_strict test.js"
}
}

@@ -1,6 +0,6 @@

#!/usr/bin/env node
var test = require('tape')
, inherits = require('inherits')
, ErrorStackParser = require('error-stack-parser')
, errno = require('./')
var test = require('tape')
, errno = require('./')
test('sanity checks', function (t) {

@@ -23,4 +23,4 @@ t.ok(errno.all, 'errno.all not found')

test('custom errors', function (t) {
var Cust = errno.create('FooNotBarError')
var cust = new Cust('foo is not bar')
const Cust = errno.create('FooNotBarError')
const cust = new Cust('foo is not bar')

@@ -33,1 +33,43 @@ t.equal(cust.name, 'FooNotBarError', 'correct custom name')

})
test('callstack', function (t) {
const MyError = errno.create('MyError')
function lastFunction (ErrorType, cb) {
process.nextTick(cb, new ErrorType('oh noes!'))
}
function secondLastFunction (ErrorType, cb) {
lastFunction(ErrorType, cb)
}
function testFrames (t) {
return function (err) {
const stack = ErrorStackParser.parse(err)
t.same(stack[0].functionName, 'lastFunction', 'last stack frame ok')
t.same(stack[1].functionName, 'secondLastFunction', 'second last stack frame ok')
t.end()
}
}
t.test('custom error, default prototype', function (t) {
secondLastFunction(MyError, testFrames(t))
})
t.test('custom error, custom prototype', function (t) {
const MyError2 = errno.create('MyError2', MyError)
secondLastFunction(MyError2, testFrames(t))
})
t.test('custom error, using inheritance', function (t) {
const CustomError = errno.custom.CustomError
function MyError3 (message, cause) {
CustomError.call(this, message, cause)
}
inherits(MyError3, CustomError)
secondLastFunction(MyError3, testFrames(t))
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc