FILE / ScuroNeko/Laniakea

tgapi/errors.go

Исходный файл и его история в репозитории.
FILE d3e4276b970e8eeb383355cb38c553deda190acf
Files
Laniakea/tgapi/errors.go
T
ScuroNeko 29b208eeec
Golang lint / lint (push) Successful in 11m32s
(new): v1.2 release
2026-08-19 14:58:25 +03:00

57 lines
2.1 KiB
Go

package tgapi
import (
"errors"
"fmt"
)
// ErrPoolUnexpected reports an unexpected result type returned from the worker pool.
var ErrPoolUnexpected = errors.New("unexpected response from pool")
// ErrPoolQueueFull reports that the internal request queue is full.
var ErrPoolQueueFull = errors.New("worker pool queue full")
// ErrPoolStopped reports that a request was submitted after the worker pool stopped.
var ErrPoolStopped = errors.New("worker pool stopped")
// ErrPoolWorkerPanic reports a panic recovered while executing a worker-pool request.
var ErrPoolWorkerPanic = errors.New("worker pool request panicked")
// ErrResponseTooLarge reports a Telegram API response larger than the safety limit.
var ErrResponseTooLarge = errors.New("telegram API response is too large")
// ErrFileTooLarge reports a file download that exceeds the caller's limit.
var ErrFileTooLarge = errors.New("telegram file exceeds size limit")
// ErrRichJSONDepth reports a rich-message JSON tree deeper than the decoder limit.
var ErrRichJSONDepth = errors.New("rich-message JSON exceeds depth limit")
// ErrRichJSONNodes reports a rich-message JSON tree larger than the decoder limit.
var ErrRichJSONNodes = errors.New("rich-message JSON exceeds node limit")
// ErrRetryLimit reports that a request exhausted its configured 429 retries.
var ErrRetryLimit = errors.New("telegram retry limit reached")
// ErrRichMessageDraftUploadUnsupported reports a direct file upload attempted for a rich draft.
//
// Since: Bot API 10.2
var ErrRichMessageDraftUploadUnsupported = errors.New("sendRichMessageDraft does not support direct file uploads")
// ResponseError reports an unsuccessful Telegram API response.
type ResponseError struct {
// Code is the Telegram API error code.
Code int
// Description is the human-readable Telegram API error description.
Description string
// Parameters contains additional recovery metadata such as retry_after.
Parameters *ResponseParameters
}
// Error returns the Telegram API error code and description.
func (e *ResponseError) Error() string {
if e == nil {
return "<nil>"
}
return fmt.Sprintf("[%d] %s", e.Code, e.Description)
}