GramIO API Reference / gramio/dist / Hooks / OnError
Type Alias: OnError()<T, Ctx>
OnError<
T,Ctx> = (options) =>unknown
Defined in: gramio/index.d.ts:714
Type for onError hook
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends ErrorDefinitions | - |
Ctx extends Context<any> | Context<AnyBot> |
Parameters
| Parameter | Type |
|---|---|
options | OnErrorContext<Ctx, T> |
Returns
unknown
Example
typescript
bot.on("message", () => {
bot.api.sendMessage({
chat_id: "@not_found",
text: "Chat not exists....",
});
});
bot.onError(({ context, kind, error }) => {
if (context.is("message")) return context.send(`${kind}: ${error.message}`);
});