INNER CODE UNIT · TypeScript
BotError
grammyjs/grammY · src/composer.ts:105
export class BotError<C extends Context = Context> extends Error {
constructor(public readonly error: unknown, public readonly ctx: C) {
super(generateBotErrorMessage(error));
this.name = "BotError";
if (error instanceof Error) this.stack = error.stack;
}
}
function generateBotErrorMessage(error: unknown) {
let msg: string;
if (error instanceof Error) {
msg = `${error.name} in middleware: ${error.message}`;
} else {
const type = typeof error;
msg = `Non-error value of type ${type} thrown in middleware`;
switch (type) {
case "bigint":
case "boolean":
case "number":