@spongex/script-error

1.0.1 • Public • Published

script-error

Function for displaying an error to console and optionally exiting

Also formats text in red

Install to your existing project using:

npm i @spongex/script-error

Include ECMAScript:

import { scriptError } from '@spongex/script-error'

Include CommonJS:

const { scriptError } = require('@spongex/script-error')

Usage

scriptError: (message: string, { exit?: boolean, code?: number }) => number

Examples:

Exit script with a code of 1:

scriptError('Something went wrong!')

Don't exit script and use a custom return code:

scriptError('Error handler', { exit: false, code: 100 })

End script with a custom error code:

scriptError('Something bad happened!', { code: 200 })

Changelog

1.0.1

  • Dependencies bump

1.0.0

  • Initial release

Dependents (5)

Package Sidebar

Install

npm i @spongex/script-error

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

5.65 kB

Total Files

8

Last publish

Collaborators

  • spongex