telega/error
Types
pub type TelegaError {
TelegramApiError(error_code: Int, description: String)
FetchError(error: String)
JsonDecodeError(error: json.DecodeError)
BotHandleUpdateError(reason: String)
ApiToRequestConvertError
SetWebhookError
NoSessionSettingsError
RegistryStartError(reason: String)
BotStartError(reason: actor.StartError)
ChatInstanceStartError(reason: actor.StartError)
FileNotFoundError
DecodeUpdateError(reason: String)
UnknownUpdateError(update: types.Update)
ActorError(reason: String)
RouterError(reason: String)
SupervisorStartError(reason: actor.StartError)
ShutdownError(reason: String)
}
Constructors
-
TelegramApiError(error_code: Int, description: String)Returned by Bot API if server returns
ok: false, indicating that your API request was invalid and failed -
FetchError(error: String)Returned if the Bot API server could not be reached or the request failed
-
JsonDecodeError(error: json.DecodeError)Returned if the JSON response from the Bot API could not be decoded
-
BotHandleUpdateError(reason: String)Returned if the bot failed to call
handle_update -
ApiToRequestConvertErrorReturned if the bot failed to convert API request to HTTP request
-
SetWebhookError -
NoSessionSettingsError -
RegistryStartError(reason: String) -
BotStartError(reason: actor.StartError) -
ChatInstanceStartError(reason: actor.StartError) -
FileNotFoundError -
DecodeUpdateError(reason: String) -
UnknownUpdateError(update: types.Update)Occurs when the update is not handled by any handler
-
ActorError(reason: String)General actor error (e.g., from polling)
-
RouterError(reason: String) -
SupervisorStartError(reason: actor.StartError) -
ShutdownError(reason: String)
Values
pub fn is_message_cant_be_edited(
error error: TelegaError,
) -> Bool
The message exists but cannot be edited (e.g. not sent by the bot).
The Bot API has no structured error codes, so a case-insensitive substring match on the 400 description is the only way to classify this error.
pub fn is_message_not_found(error error: TelegaError) -> Bool
The message to edit no longer exists (deleted by the user or too old).
The Bot API has no structured error codes, so a case-insensitive substring match on the 400 description is the only way to classify this error.
pub fn is_message_not_modified(error error: TelegaError) -> Bool
The edit was a no-op: new content equals the current one. Safe to treat as success.
The Bot API has no structured error codes, so a case-insensitive substring match on the 400 description is the only way to classify this error.
pub fn to_string(error: TelegaError) -> String
pub fn try(
result: Result(a, TelegaError),
to to_error: fn(TelegaError) -> e,
fun fun: fn(a) -> Result(b, e),
) -> Result(b, e)
Helper to replace result.try for api call and error mapping.