From 925f2d9924d91a7599072981863c3bf3f47283be Mon Sep 17 00:00:00 2001 From: Ivan Kalashnikov Date: Wed, 29 Oct 2025 16:08:38 +0700 Subject: [PATCH] fix: replace numeric error codes with http constants. --- raw_request.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/raw_request.go b/raw_request.go index 4457d06..755e55e 100644 --- a/raw_request.go +++ b/raw_request.go @@ -102,9 +102,9 @@ func (b *Bot) rawRequest(ctx context.Context, method string, params any, dest an if !r.OK { switch r.ErrorCode { - case 403: + case http.StatusForbidden: return fmt.Errorf("%w, %s", ErrorForbidden, r.Description) - case 400: + case http.StatusBadRequest: if r.Parameters.MigrateToChatID != 0 { err := &MigrateError{ Message: fmt.Sprintf("%s: %s", ErrorBadRequest, r.Description), @@ -114,13 +114,13 @@ func (b *Bot) rawRequest(ctx context.Context, method string, params any, dest an return err } return fmt.Errorf("%w, %s", ErrorBadRequest, r.Description) - case 401: + case http.StatusUnauthorized: return fmt.Errorf("%w, %s", ErrorUnauthorized, r.Description) - case 404: + case http.StatusNotFound: return fmt.Errorf("%w, %s", ErrorNotFound, r.Description) - case 409: + case http.StatusConflict: return fmt.Errorf("%w, %s", ErrorConflict, r.Description) - case 429: + case http.StatusTooManyRequests: err := &TooManyRequestsError{ Message: fmt.Sprintf("%s, %s", ErrorTooManyRequests, r.Description), RetryAfter: r.Parameters.RetryAfter,