npm.io
4.4.3 • Published 5d ago

cli-handle-error

Licence
MIT
Version
4.4.3
Deps
3
Size
6 kB
Vulns
0
Weekly
0
Stars
12

cli-handle-error

DOWNLOADS Learn VSCode Follow @MrAhmadAwais on X

Custom error handler for Node CLIs


Install

npm install cli-handle-error

Usage

const handleError = require('cli-handle-error');

// Let's say we get an error message from a custom command.
const [err, res] = await somePromise();

// Use the function. It will print the error and exit if there is an error.
handleError(`Failed while building on step #1`, err);

API

handleError(heading, err, displayError?, exit?)
❯ heading

Type: string

Heading of the error message.

❯ err

Type: error/object

❯ displayError

Type: boolean
Default: true (optional)

Display the error message or not.

❯ exit

Type: boolean
Default: true (optional)

Exit the CLI on error or not?


Changelog

❯ Read the changelog here →


KEY: 📦 NEW, 👌 IMPROVE, 🐛 FIX, 📖 DOC, 🚀 RELEASE, and ✅ TEST

I use Emoji-log, you should try it and simplify your git commits.


License & Conduct


Connect

X @MrAhmadAwais LinkedIn @MrAhmadAwais YouTube AhmadAwais Blog: AhmadAwais.com GitHub @AhmadAwais

❯❯ Professional Development Courses ↓

Node CLI Course VSCode Course Node.js Course

Keywords