New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

error-value

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-value

Errors as values

latest
Source
npmnpm
Version
0.4.4
Version published
Weekly downloads
45
-75.27%
Maintainers
1
Weekly downloads
 
Created
Source

Errors as values

Error constructor for Maybe Monads.

Features

  • code first, message optional
  • instance of Error
  • no stack trace
  • serializable

API

  • Err(code: string, message?: string)
  • Err(code: string, details?: object)

Examples

import { Err } from 'error-value'
const err = Err('BAD')

console.log(err instanceof Error) // true
console.log(err.code) // 'BAD'
const err = Err('BAD', 'Something bad happened')

console.log(err.message) // 'Something bad happened'
const err = Err('BAD', { foo: 'bar' })

console.log(err.foo) // 'bar'
console.log(JSON.stringify(err)) // '{"code":"BAD","foo":"bar"}'

Keywords

javascript

FAQs

Package last updated on 05 Dec 2024

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