PopiiError
Popii / PopiiError
Class: PopiiError
Section titled “Class: 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.
Example
Section titled “Example”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...}Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PopiiError(
message,code,hint?,path?):PopiiError
Defined in: utils/error.ts:36
Parameters
Section titled “Parameters”message
Section titled “message”string
string
string
string
Returns
Section titled “Returns”PopiiError
Overrides
Section titled “Overrides”Error.constructor
Properties
Section titled “Properties”code:
string
Defined in: utils/error.ts:30
Machine-readable error code for programmatic handling (e.g. "INSUFFICIENT_FUNDS").
optionalhint?:string
Defined in: utils/error.ts:32
Optional user-facing hint shown below the error message.
optionalpath?:string
Defined in: utils/error.ts:34
Optional file path or context string for internal debugging.