Err

Bajo error class, a thin wrapper of node's Error object.

Every Bajo plugin has a built-in method called error which basically the shortcut to create a new Err instance. It helps you create this instance anywhere in your code quickly without the hassle of importing & instantiating:

... anywhere inside your code
if (notfound) throw this.error('Sorry, item is nowhere to be found!')

Constructor

new Err(plugin, msg, …argsopt)

Parameters:
NameTypeAttributesDescription
pluginPlugin

Plugin instance

msgstring

Error message

argsany<optional>
<repeatable>

Variables to interpolate with error message. Payload object can be pushed at the very last argument

Members

app :App

The app instance

Type:

message :string

Translated message

Type:
  • string

orgMessage :string

Original message before translation

Type:
  • string

payload :Object

Error payload extracted from the last arguments

Type:
  • Object

plugin :Plugin

Attached plugin

Type:

Methods

fatal()

Print instance on console and terminate process

formatErrorDetails(value) → {Object}

Pretty format error details

Parameters:
NameTypeDescription
valueObject

Value to format

Returns:
Type: 
Object

write() → {Err}

Write message to the console

Returns:

Error object, usefull for chaining

Type: 
Err