New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ogcio/fastify-error-handler

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ogcio/fastify-error-handler

Normalize the error handling of errors with related logs

  • 5.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
increased by68.42%
Maintainers
0
Weekly downloads
 
Created
Source

Fastify Error Handler

This error handler package's goal is to standardize the management of the errors across Fastify services.

How to use it

To use this package 2 steps are needed:

  • install the package with
npm i @ogcio/fastify-error-handler
  • use the initializeErrorHandler(server) method to set the error handlers for the fastify server

That's it!

How to raise errors

To standardize error handling in the Fastify services, the suggested way to go is to raise exceptions by using the HttpError errors from the fastify-sensible package.

It exposes some predefined error types

import { httpErrors } from "@fastify/sensible";
......
// predefined error
throw httpErrors.notFound("Route not found");

// custom error
throw httpErrors.createError(404, "message", {additional: {data: "here"}});

The error-handler package is ready to manage the errors, log them and transform them in the output HTTP error you need.

FAQs

Package last updated on 29 Nov 2024

Did you know?

Socket

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.

Install

Related posts

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