Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

trycatch

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trycatch - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

6

lib/formatError.js

@@ -79,3 +79,3 @@ var path = require('path')

for (j=0, m=options.filter.length; j<m; j++) {
if (line.indexOf(options.filter[j]) !== -1) {
if (line && line.indexOf(options.filter[j]) !== -1) {
line = ''

@@ -99,4 +99,6 @@ }

type = "default";
} else if (line.indexOf('(') >= 0) {
type = "node"
} else {
type = "node"
return line
}

@@ -103,0 +105,0 @@

@@ -8,3 +8,3 @@ var util = require('util')

, normalizeError = require('./formatError').normalizeError
, fileNameFilter = [path.dirname(__filename), require.resolve('hookit'), 'domain.js', 'Domain.emit']
, defaultFileNameFilter = [path.dirname(__filename), require.resolve('hookit'), 'domain.js', 'Domain.emit']
, delimitter = '\n ----------------------------------------\n'

@@ -23,3 +23,3 @@ , originalError = global.Error

, 'format': null
, 'filter': fileNameFilter
, 'filter': defaultFileNameFilter
}

@@ -249,4 +249,8 @@

if (Array.isArray(opts.filter)) {
options.filter = opts.filter
if (undefined !== opts.filter) {
if (null === opts.filter) {
options.filter = defaultFileNameFilter
} else if (Array.isArray(opts.filter)) {
options.filter = defaultFileNameFilter.concat(opts.filter)
}
}

@@ -253,0 +257,0 @@

{
"name": "trycatch",
"version": "1.3.1",
"version": "1.3.2",
"description": "An asynchronous domain-based exception handler with long stack traces for node.js",

@@ -47,4 +47,5 @@ "homepage": "http://github.com/CrabDude/trycatch",

"mocha": "~1.4.0",
"underscore": "~1.3.3"
"underscore": "~1.3.3",
"lodash": "^2.4.1"
}
}
var trycatch = require('../lib/trycatch')
, assert = require('assert')
, _ = require('lodash')
, delimitter = '\n ----------------------------------------'

@@ -15,31 +17,67 @@ /*

'long-stack-traces': Boolean(longStackTraces)
, colors: {
node: 'red'
, node_modules: 'red'
, default: 'red'
}
, filter: null
})
})
it.skip('should be colored', function(done) {
setTimeout(function() {
throw new Error('test 1')
it('should be colored', function() {
new Error().stack.split('\n').forEach(function(value, key) {
if (key === 0) return
assert.equal(value.charCodeAt(0), 27)
assert.equal(value.substring(1,5), '[31m')
})
})
it.skip('should be filtered: internal', function(done) {
setTimeout(function() {
throw new Error('test 1')
it('should be filtered: internal', function() {
var stack = new Error().stack.split('\n')
, success
success = _.every(stack, function(value, key) {
return !_.some(['trycatch.js', 'formatError.js', 'hookit'], function(filePattern, key) {
return _.contains(value, filePattern)
})
})
assert(success)
})
it.skip('should be filtered: configurable', function(done) {
setTimeout(function() {
throw new Error('test 1')
it('should be filtered: configurable', function() {
var stack
trycatch.configure({
colors: {
node: false
, node_modules: false
, default: 'red'
}
})
stack = new Error().stack.split(delimitter)[0].split('\n')
assert.equal(stack.length, 2)
})
it.skip('should be filtered: line', function(done) {
setTimeout(function() {
throw new Error('test 1')
it('should be filtered: line', function() {
var stack
trycatch.configure({
filter: ['trycatch']
})
stack = new Error().stack.split(delimitter)[0].split('\n')
assert.equal(stack.length, 1)
})
it.skip('should be ' + longStackTraces ? 'long' : 'short', function(done) {
var delimitter = '----------------------------------------'
setTimeout(function() {
throw new Error('test 1')
})
it('should be ' + longStackTraces ? 'long' : 'short', function() {
var stack
, index
trycatch.configure({'long-stack-traces': longStackTraces})
stack = new Error().stack
index = stack.indexOf(delimitter)
assert[longStackTraces ? 'notEqual' : 'equal'](index, -1)
})

@@ -46,0 +84,0 @@ })

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