Skip to content

default traceback not helpful in case of server errors #115

@FelixSchwarz

Description

@FelixSchwarz

If the server responds with a non-200 response, openapi3 produces an exception which is not really helpful. It would be nice if the default traceback contained the server response body (in this case "Request body must not be empty")

Traceback (most recent call last):
  File "client.py", line 33, in <module>
    result = api.call_post_greeting(parameters={'name': 'foo'})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "…/venv/lib64/python3.12/site-packages/openapi3/openapi.py", line 256, in __call__
    return self.operation(self.base_url, *args, security=self.security, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "…/venv/lib64/python3.12/site-packages/openapi3/paths.py", line 359, in request
    raise UnexpectedResponseError(result, self)
openapi3.errors.UnexpectedResponseError: Unexpected response 400 from post_greeting (expected one of 200, no default is defined)

str(exc) returns UnexpectedResponseError('Unexpected response 400 from post_greeting (expected one of 200, no default is defined)') so that would be nice to see also for uncaught exceptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions