Skip to content

[BUG] Error codes #2162

@Bibo-Joshi

Description

@Bibo-Joshi

if resp.status in (401, 403):
raise Unauthorized(message)
elif resp.status == 400:
raise BadRequest(message)
elif resp.status == 404:
raise InvalidToken()
elif resp.status == 409:
raise Conflict(message)
elif resp.status == 413:
raise NetworkError(
'File too large. Check telegram api limits '
'https://core.telegram.org/bots/api#senddocument'
)

We currently raise InvalidToken for 404, though 404 seems to be raised when requesting non-existing methods.
Unauthorized (=401) is the acutal InvalidToken and 403 gives Forbidden. So

  • 401 -> Unauthorized
  • 403 -> Forbidden
  • drop InvalidToken/only use it in Bot._validate_token

I do think we should update that. However those are pretty much breaking changes, so probably only in the next major release …

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions