
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
@kabeep/exception
Advanced tools
Exception is a custom error library for Node.js that provides a more flexible and customizable way of handling errors.
Exception is a custom error library for Node.js that provides a more flexible and customizable way of handling errors.
English | 简体中文
Inspired by the work of sindresorhus, I decided to open source the most repetitive encapsulation work I do in CLI development.
I do not like disorder. Often, unexpected situations arise due to our insufficient consideration. Therefore, I encourage those around me to engage in more comprehensive error collection work.
The goal of Exception is to transform unexpected occurrences into anticipated outcomes as much as possible.
It allows Error objects to throw exception and stack information in a more aesthetically pleasing and intuitive manner, and can also serve as Notify to output critical information in workflows.
npm install @kabeep/exception --save
yarn add @kabeep/exception
pnpm add @kabeep/exception

import Exception from '@kabeep/exception';
// Plain text
throw new Exception('Argument example');
// or Error object
throw new Exception(new Error('Argument example'));

import Exception from '@kabeep/exception';
(
async () => {
throw new Exception('Promise example');
}
)().catch(console.log);

import Exception from '@kabeep/exception';
// Use custom style with hex or rgb
const stylish = '(51,51,51).bg#f56c6c';
console.log(
new Exception('Stylish example', stylish)
);

import Exception from '@kabeep/exception';
// > Warning
class Warning extends Exception {
constructor (message: string | Error) {
super(message, '( 51 ,51, 51 ).bg#e6a23c');
}
}
const warn = new Warning('Inherited example');
// Warning: Inherited example [Without style]
console.log(`${warn}`);
console.log(warn);

import Exception from '@kabeep/exception';
// > Info
const infoStyle = '(51,51,51).bg#409eff';
class Info extends Exception {
constructor (message) {
super(message, infoStyle);
}
toString () {
return this.info(styles);
}
}
const tip = new Info('Inherited example');
// Without stack
console.log(`${tip}`);
// > Success
const successStyle = '(51,51,51).bg#67c23a';
class Success extends Exception {
constructor (message) {
super(message, successStyle);
}
toString () {
return this.info(styles);
}
}
const pass = new Success('Inherited example');
// Without stack
console.log(pass.toString());
"dim.italic.underline"
"magenta.cyan"
"bgMagenta.bgCyan"
"#fff.bg#333333"
"(51,51,51).bg(24,124,255)"
"cyan.bgDarkblue"
Contributions via Pull Requests or Issues are welcome.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
A Node.js Custom Error Library that print error stack without clutter.
The npm package @kabeep/exception receives a total of 28 weekly downloads. As such, @kabeep/exception popularity was classified as not popular.
We found that @kabeep/exception demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.