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

@tractor/error-handler

Package Overview
Dependencies
Maintainers
7
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tractor/error-handler

JavaScript file handler for tractor

  • 1.9.4-tractor-to-playwright.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-40%
Maintainers
7
Weekly downloads
 
Created
Source

@tractor/error-handler

A general HTTP request error handler for tractor.

npm version

API

new TractorError (message: string, status?: number)

Create a new TractorError.

const error = new TractorError('something bad happened', 500);

TractorError.isTractorError (err: TractorError | any): boolean

Checks if something is a TractorError.

TractorError.isTractorError(new TractorError('something bad happened')); // true;
TractorError.isTractorError(new Error('something bad happened')); // false;

handleError (response: Response, err: TractorError, message?: string): void

Sends an error back to the client, via the Express HTTP response object.

import { TractorError, handleError } from '@tractor/error-handler';

export function myApiEndpoint (request: Request, response: Response): void {
    if (somethingBad) {
        handleError(response, new TractorError('something bad happened'));
    } else {
        response.sendStatus(200);
    }
}

FAQs

Package last updated on 10 Aug 2021

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