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
import { PopiiError } from"popii";
asyncdo(pop) { constbalance = pop.locals.dbUser.balance; if (balance < 100) { thrownewPopiiError( "You don't have enough coins!", "INSUFFICIENT_FUNDS", "Check your balance with /balance" ); } // deduct and proceed... }
A structured, user-facing error for expected failure conditions.
When
errorHandlerPlugin()is active, throwing aPopiiErrorinside a command handler will display themessage(and optionalhint) 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