🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

@map-colonies/error-express-handler

Package Overview
Dependencies
Maintainers
11
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@map-colonies/error-express-handler

Express error handler for the MapColonies project

latest
Source
npmnpm
Version
4.0.0
Version published
Weekly downloads
417
-23.35%
Maintainers
11
Weekly downloads
 
Created
Source

error-express-handler

This package exports a middleware for express that handles Error and HttpError(custom package type).

Install

npm install --save @map-colonies/error-express-handler

API documentation

Check the autogenerated documentation here.

Usage

Add the handler as the last middleware, so any error forwarded by the controllers will be handled. If the value of NODE_ENV is production the error message will be redacted and a generic one will be sent instead. In development, in addition to the error message, the stack trace of the error will be included in the response.

import express from 'express';
import { getErrorHandlerMiddleware } from '@map-colonies/error-express-handler';

process.env.NODE_ENV = 'development';

const app = express();

app.use('/meow', fn);

app.use(getErrorHandlerMiddleware());

app.listen(8080, function() {
    console.log('server is up');
});

Flow

flowchart TD
    A@{ label: "NODE_ENV='production'" } -- true --> B["error implements HttpError"]
    A -- false --> C["error implements HttpError"]
    B -- true --> D["Status code: err.StatusCode<br>body: {fl°°34¶ßmessagefl°°34¶ß:fl°°34¶ßerr.messagefl°°34¶ß}"]
    B -- false --> E["Status code: 500<br>body: {fl°°34¶ßmessagefl°°34¶ß:fl°°34¶ßInternal Server Errorfl°°34¶ß}"]
    C -- true --> F["Status code: err.StatusCode<br>body: {fl°°34¶ßmessagefl°°34¶ß:fl°°34¶ßerr.messagefl°°34¶ß}"]
    C -- false --> G["Status code: 500<br>body: {fl°°34¶ßmessagefl°°34¶ß:fl°°34¶ßInternal Server Errorfl°°34¶ß, fl°°34stacktracefl°°34:err.stack }"]

FAQs

Package last updated on 19 Jan 2026

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