docs(telegram): plain the permanent-failure comments (#2016)
publish / publish (push) Successful in 3m6s
publish / publish (push) Successful in 3m6s
This commit is contained in:
2 files changed
+7
-6
No files matched your search
@@ -289,8 +289,8 @@ func (t *telegram) call(ctx context.Context, method string, body, out any) error
|
||||
}
|
||||
if !env.OK {
|
||||
err := fmt.Errorf("%s: %s", method, env.Description)
|
||||
// Telegram answers 400, 403 and 404 for a request it will refuse
|
||||
// again: a bad message, a blocked bot, a missing chat.
|
||||
// Telegram returns 400, 403 and 404 for requests that will fail again:
|
||||
// an invalid message, a blocked bot or a missing chat.
|
||||
switch cmp.Or(env.ErrorCode, res.StatusCode) {
|
||||
case http.StatusBadRequest, http.StatusForbidden, http.StatusNotFound:
|
||||
return connector.Permanent(err)
|
||||
|
||||
@@ -2,15 +2,16 @@ package connector
|
||||
|
||||
import "errors"
|
||||
|
||||
// permanentError marks a delivery failure no retry can fix.
|
||||
// permanentError marks a delivery failure that retrying cannot fix.
|
||||
type permanentError struct{ err error }
|
||||
|
||||
func (e *permanentError) Error() string { return e.err.Error() }
|
||||
func (e *permanentError) Unwrap() error { return e.err }
|
||||
|
||||
// Permanent marks err as a refusal the same delivery will meet again, such as a
|
||||
// message the service says is invalid or a chat that is gone. The host records
|
||||
// the reason and stops retrying it; any other Deliver error is retried.
|
||||
// Permanent marks err as a permanent rejection that the same delivery would
|
||||
// receive again, such as a message the service considers invalid or a chat
|
||||
// that no longer exists. The host records the reason and stops retrying; any
|
||||
// other Deliver error is retried.
|
||||
func Permanent(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user