| name | error-handling |
| description | This skill should be used when the user asks about "grammY error handling", "bot.catch", "GrammyError", "HttpError", "BotError", "errorBoundary", "bot crashed", "unhandled promise rejection in bot", or needs to understand the three error types grammY throws and how to catch them. |
grammY — Error Handling
grammY wraps every middleware error into a BotError and routes it to bot.catch. There are exactly three error classes you ever need to know.
The three error types
| Type | Thrown when | How to inspect |
|---|
GrammyError | Bot API responded with ok: false. Your request reached Telegram but Telegram rejected it (bad parameter, no permission, blocked by user, etc.) | err.description, err.error_code, err.parameters |
HttpError | Could not reach Telegram at all — DNS, TLS, timeout, network down | err.error (the underlying network error) |
BotError<C> | Wraps any error thrown from middleware. Contains both the original error AND the update context that triggered it | err.error, err.ctx |
BotError is always what reaches bot.catch. Its .error property holds the real cause (a GrammyError, HttpError, or any other thrown value).
The canonical bot.catch handler
import { , , } ;
bot = (process..!);
bot.( {
ctx = err.;
.();
e = err.;
(e ) {
.(, e.);
} (e ) {
.(, e);
} {
.(, e);
}
});