Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 880 Bytes

File metadata and controls

37 lines (25 loc) · 880 Bytes

Errors

Functions for throwing errors.

fail(message) {#fail}

This function throws an error with a message constructed by concatenating all arguments passed to it.

fail('Failed to ', 'insert', ' record');
// -> throws error with message 'Failed to insert record'

The benefit of using this function over throw is that it can be used in an expression.

const x = params.x || fail('No x specified');

failMsg(message, data) {#failMsg}

This function throws an error with a message generated from expanding a message template using the format() function.

failMsg('Failed to <action> record', { action: 'insert' })
// -> throws error with message 'Failed to insert record'

rethrow(error) {#rethrow}

Function to rethrow an error. The benefit of using this function over throw is that it can be used in an expression.