@fastify/error
Advanced tools
Comparing version 3.4.0 to 3.4.1
@@ -26,3 +26,3 @@ 'use strict' | ||
const lastElement = args.length - 1 | ||
if (lastElement !== 1 && args[lastElement] && typeof args[lastElement] === 'object' && 'cause' in args[lastElement]) { | ||
if (lastElement !== -1 && args[lastElement] && typeof args[lastElement] === 'object' && 'cause' in args[lastElement]) { | ||
this.cause = args.pop().cause | ||
@@ -29,0 +29,0 @@ } |
{ | ||
"name": "@fastify/error", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"description": "A small utility, used by Fastify itself, for generating consistent error objects across your codebase and plugins.", | ||
"main": "index.js", | ||
"type": "commonjs", | ||
"types": "types/index.d.ts", | ||
@@ -7,0 +8,0 @@ "scripts": { |
'use strict' | ||
const test = require('tap').test | ||
const { test } = require('tap') | ||
const createError = require('..') | ||
@@ -166,2 +166,12 @@ | ||
test('Create an error with cause and message', t => { | ||
t.plan(2) | ||
const cause = new Error('HEY') | ||
const NewError = createError('CODE', 'Not available: %s') | ||
const err = NewError('foo', { cause }) | ||
t.ok(err instanceof Error) | ||
t.equal(err.cause, cause) | ||
}) | ||
test('Create an error with last argument null', t => { | ||
@@ -168,0 +178,0 @@ t.plan(2) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18460
15
326