1.2.0 • Published 2 years ago

firescript-error v1.2.0

Weekly downloads
130
License
MIT
Repository
-
Last release
2 years ago

Firescript Error

Error base class for Firescript

import FirescriptError from 'firescript-error'

export class MyError extends FirescriptError
    constructor (...args)
        super(...args)
        this.name = 'MyError'
        this.code = 'MY_ERR_CODE'

.from(obj err)

Create FirescriptError styled error from an error object

try
    # some error happens
catch err
    throw FirescriptError.from(err)

Colors

Error messages are pretty colorized in the CLI. The FirescriptError module detects whether the stdout is a tty terminal or not and set the colormode based on this information. You can control the colormode by setting an env variable called FIRESCRIPT_ERROR_COLORS

export FIRESCRIPT_ERROR_COLORS=1 # enable error colors
export FIRESCRIPT_ERROR_COLORS=0 # disable error colors