Handling Errors
All errors are a subclass of RPCError
which has a .code
and a .message
attribute.
Custom errors
GramJS provides some custom helper classes that subclass RPCError like FloodWaitError
which has a .seconds
attribute telling you how long to sleep before calling the same request again.
These errors aren't generated and can be found in RPCErrorList
.
Handling flood wait errors
The most common error is the FloodWait
error which is caused by calling a method multiple times in a short period and acts as a spam filter from telegram.
By default, GramJS sleeps when the floodwait
is lower than 60 seconds but this threshold can be easily changed with the floodSleepThreshold
setter.
client.floodSleepThreshold = 300; // sleeps if the wait is lower than 300 seconds
The longest wait possible is 1 day which is 24 * 60 * 60
seconds
Last updated
Was this helpful?