
Research
TeamPCP Compromises Telnyx Python SDK to Deliver Credential-Stealing Malware
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.
@fastify/error
Advanced tools
A small utility, used by Fastify itself, for generating consistent error objects across your codebase and plugins.
A small utility, used by Fastify itself, for generating consistent error objects across your codebase and plugins.
npm i @fastify/error
The module exports a function that you can use for consistent error objects, it takes 4 parameters:
createError(code, message [, statusCode [, Base [, captureStackTrace]]])
code (string, required) - The error code, you can access it later with error.code. For consistency, we recommend prefixing plugin error codes with FST_message (string, required) - The error message. You can also use interpolated strings for formatting the message.statusCode (number, optional) - The status code that Fastify will use if the error is sent via HTTP.Base (ErrorConstructor, optional) - The base error object that will be used. (eg TypeError, RangeError)captureStackTrace (boolean, optional) - Whether to capture the stack trace or not.const createError = require('@fastify/error')
const CustomError = createError('ERROR_CODE', 'Hello')
console.log(new CustomError()) // error.message => 'Hello'
How to use an interpolated string:
const createError = require('@fastify/error')
const CustomError = createError('ERROR_CODE', 'Hello %s')
console.log(new CustomError('world')) // error.message => 'Hello world'
How to add cause:
const createError = require('@fastify/error')
const CustomError = createError('ERROR_CODE', 'Hello %s')
console.log(new CustomError('world', {cause: new Error('cause')}))
// error.message => 'Hello world'
// error.cause => Error('cause')
It is possible to limit your error constructor with a generic type using TypeScript:
const CustomError = createError<[string]>('ERROR_CODE', 'Hello %s')
new CustomError('world')
//@ts-expect-error
new CustomError(1)
Licensed under MIT.
Similar to @fastify/error, http-errors is a package for generating HTTP errors for Node.js web applications. While @fastify/error is tailored for Fastify applications, http-errors is more generic and can be used with any Node.js web framework.
Boom provides a set of utilities for returning HTTP errors. It offers more predefined errors compared to @fastify/error. However, @fastify/error allows for more customization in defining error constructors with default messages and status codes.
FAQs
A small utility, used by Fastify itself, for generating consistent error objects across your codebase and plugins.
The npm package @fastify/error receives a total of 5,365,173 weekly downloads. As such, @fastify/error popularity was classified as popular.
We found that @fastify/error demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 20 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.

Security News
/Research
Widespread GitHub phishing campaign uses fake Visual Studio Code security alerts in Discussions to trick developers into visiting malicious website.