Skip to content

PopiiError

Popii


Popii / PopiiError

Defined in: utils/error.ts:28

A structured, user-facing error for expected failure conditions.

When errorHandlerPlugin() is active, throwing a PopiiError inside a command handler will display the message (and optional hint) to the user as an ephemeral reply, without logging a stack trace. Use it for business-logic errors you want to communicate cleanly rather than crash silently.

import { PopiiError } from "popii";
async do(pop) {
const balance = pop.locals.dbUser.balance;
if (balance < 100) {
throw new PopiiError(
"You don't have enough coins!",
"INSUFFICIENT_FUNDS",
"Check your balance with /balance"
);
}
// deduct and proceed...
}
  • Error

new PopiiError(message, code, hint?, path?): PopiiError

Defined in: utils/error.ts:36

string

string

string

string

PopiiError

Error.constructor

code: string

Defined in: utils/error.ts:30

Machine-readable error code for programmatic handling (e.g. "INSUFFICIENT_FUNDS").


optional hint?: string

Defined in: utils/error.ts:32

Optional user-facing hint shown below the error message.


optional path?: string

Defined in: utils/error.ts:34

Optional file path or context string for internal debugging.