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

@tractor/error-handler

Package Overview
Dependencies
Maintainers
1
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.0.0-alpha.6
  • Source
  • npm
  • Socket score

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

@tractor/error-handler

A general HTTP request error handler for tractor.

npm version

API:

TractorError:

Creates a new TractorError.

Arguments:
  • message: string - the error message
  • status?: number - the HTTP status of the error
Usage:
let error = new TractorError('something bad happened', 500);

TractorError.isTractorError:

Checks if something is a TractorError.

Arguments:
  • e: any - thing to test
Usage:
TractorError.isTractorError(new TractorError('something bad happened')); // true;
TractorError.isTractorError(new Error('something bad happened')); // false;

handleError:

Sends an error back to the client

Arguments:
  • response: Response - the Express HTTP response object
  • error: TractorError - the TractorError that was thrown
Usage:
import { TractorError, handleError } from '@tractor/error-handler';

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

FAQs

Package last updated on 08 Feb 2018

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