Error constructor for Maybe Monads.
code
first,message
optional- instance of
Error
- no stack trace
- serializable
Err(code: string, message?: string)
Err(code: string, details?: object)
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"}'