Skip to content

Improve APIError default exception messages #5

@pederhan

Description

@pederhan

When an uncaught exception is raised because of an HTTP status error, no useful information is printed by default.

Take this example of a traceback (rich-formatted in this case):

│ /Users/pederhan/repos/mreg-tools/.venv/lib/python3.14/site-packages/mreg_api/client.py:610 in _check_response                                            │
│                                                                                                                                                          │
│    607 │   │   │   else:                                                                                                                                 │
│    608 │   │   │   │   msg = response.text                                                                                                               │
│    609 │   │   │   cls = determine_http_error_class(operation_type)                                                                                      │
│ ❱  610 │   │   │   raise cls(msg, response)                                                                                                              │
│    611 │                                                                                                                                                 │
│    612 │   def request(                                                                                                                                  │
│    613 │   │   self,                                                                                                                                     │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
GetError: 500 Internal Server Error

I suppose we should try to include response text?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions