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

@dotcom-reliability-kit/errors

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotcom-reliability-kit/errors

A suite of error classes which help you throw the most appropriate error in any situation

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4K
decreased by-1.92%
Maintainers
3
Weekly downloads
 
Created
Source

@dotcom-reliability-kit/errors

A suite of error classes which help you throw the most appropriate error in any situation, and identify when errors are known vs unknown. This module is part of FT.com Reliability Kit.

Usage

Install @dotcom-reliability-kit/errors as a dependency:

npm install --save @dotcom-reliability-kit/errors

Include in your code:

import {OperationalError} from '@dotcom-reliability-kit/errors';
// or
const {OperationalError} = require('@dotcom-reliability-kit/errors');

This module exports different Error classes which have different jobs. All can be imported in the same way as the example above.

OperationalError

The OperationalError class is the base class for most other error types. "Operational" in this context means "we understand why this error has occurred", so by using this error type you're helping your team to understand when a thrown error is unexpected.

It works in the same way as a normal error, expecting a message:

throw new OperationalError('example message');
OperationalError.isErrorMarkedAsOperational()

You can test whether an error is operational (known about) either by using the isErrorMarkedAsOperational method. It accepts an error object of any kind and will return true if that error has a truthy isOperational property and false otherwise:

OperationalError.isErrorMarkedAsOperational(new OperationalError('example message')); // true
OperationalError.isErrorMarkedAsOperational(new Error('example message')); // false

Contributing

See the central contributing guide for Reliability Kit.

License

Licensed under the MIT license.
Copyright © 2022, The Financial Times Ltd.

FAQs

Package last updated on 04 May 2022

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