Skip to content

Function: describeError() ​

describeError(error): ErrorDescription

Describe an error as the JSON responders send it: its errno (or code, E_UNKNOWN without either) and its errMsg (or message, or the error converted to a string).

Parameters ​

error ​

unknown

The error, any value.

Returns ​

ErrorDescription

The error's number and message.

Example ​

typescript
import {describeError, type ErrorDescription} from 'lakutata/adapter/express'

const description: ErrorDescription = describeError(new Error('Boom'))
console.log(description) //{errno: 'E_UNKNOWN', errMsg: 'Boom'}

Released under the MIT License.