npm.io
1.0.5 • Published 22h ago

@arcscord/better-error

Licence
MIT
Version
1.0.5
Deps
0
Size
55 kB
Vulns
0
Weekly
15

@arcscord/better-error

npm version Discord

A lightweight extension of the native Error class that adds structured debug context. When something goes wrong deep in a call stack, it is often useful to attach extra information — the file that was being processed, the value that caused the issue, the step that failed — without having to encode everything into the error message string.

BaseError accepts a debugs object alongside the message, keeping diagnostic data structured and inspectable rather than buried in a formatted string. It is used throughout the arcscord ecosystem as the base class for all framework errors.

Install

pnpm add @arcscord/better-error

Example

import { BaseError } from "@arcscord/better-error";

const error = new BaseError({
  message: "Failed to load config",
  debugs: {
    path: "/etc/bot/config.json",
    reason: "file not found",
  },
});

console.error(error.message); // "Failed to load config"
console.error(error.debugs); // { path: "...", reason: "..." }

License

MIT

Keywords