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

@keepkey/errors

Package Overview
Dependencies
Maintainers
9
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keepkey/errors

Common set of typed errors

  • 1.1.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
9
Weekly downloads
 
Created
Source

@shapeshiftoss/errors

This package contains named errors and a function to create new named errors

Installation

It's recommend to add this package to peerDependencies to avoid duplicate versions of the package which will cause instanceof checks to fail.

Usage

import { ValidationError } from '@shapeshiftoss/errors'

throw new ValidationError('txId cannot be null', { details: { name: 'txId', expected: 'not null', actual: 'null' }})

Create a new named error

import { createErrorClass } from '@shapeshiftoss/errors'

const MyError = createErrorClass<{ myDetails: string }>('MyError')

try {
  throw new MyError('My cool error', { details: { myDetails: 'string' } })
} catch (e) {
  assert.ok(e instanceof MyError)
}

Error.code

All errors support a code property. This property is designed to be used for internationalization so that translated text can be displayed based on the code rather than on the message.

import { RateLimitError } from '@shapeshiftoss/errors'

const e = new RateLimitError('Something bad happened', { code: 'ERR_RATE_LIMIT_INFURA' })

Types

ForbiddenError - Authorized but not allowed access request resource
NotFoundError - Can not find requested entity
RateLimitError - API returned a 429 error
UnauthorizedError - Trying to access a protected resource
ValidationError - Invalid data provided

FAQs

Package last updated on 05 Nov 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