connexion.exceptions

This module defines Exception classes used by Connexion to generate a proper response.

Module Contents

exception connexion.exceptions.ConnexionException

Bases: Exception

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.ProblemException(status=400, title=None, detail=None, type=None, instance=None, headers=None, ext=None)

Bases: ConnexionException

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.ResolverError(reason='Unknown reason', exc_info=None)

Bases: LookupError

Base class for lookup errors.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.InvalidSpecification

Bases: ConnexionException, jsonschema.exceptions.ValidationError

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

__unicode__(self)
classmethod create_from(cls, other)
property absolute_path(self)
property absolute_schema_path(self)
exception connexion.exceptions.NonConformingResponse(reason='Unknown Reason', message=None)

Bases: ProblemException

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.AuthenticationProblem(status, title, detail)

Bases: ProblemException

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.ResolverProblem(status, title, detail)

Bases: ProblemException

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.BadRequestProblem(title='Bad Request', detail=None)

Bases: ProblemException

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.UnsupportedMediaTypeProblem(title='Unsupported Media Type', detail=None)

Bases: ProblemException

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.NonConformingResponseBody(message, reason='Response body does not conform to specification')

Bases: NonConformingResponse

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.NonConformingResponseHeaders(message, reason='Response headers do not conform to specification')

Bases: NonConformingResponse

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.OAuthProblem(description=None, response=None, www_authenticate=None)

Bases: werkzeug.exceptions.Unauthorized

401 Unauthorized

Raise if the user is not authorized to access a resource.

The www_authenticate argument should be used to set the WWW-Authenticate header. This is used for HTTP basic auth and other schemes. Use WWWAuthenticate to create correctly formatted values. Strictly speaking a 401 response is invalid if it doesn’t provide at least one value for this header, although real clients typically don’t care.

Parameters
  • description – Override the default message used for the body of the response.

  • www-authenticate – A single value, or list of values, for the WWW-Authenticate header.

Changed in version 0.15.3: If the www_authenticate argument is not set, the WWW-Authenticate header is not set.

Changed in version 0.15.3: The response argument was restored.

Changed in version 0.15.1: description was moved back as the first argument, restoring its previous position.

Changed in version 0.15.0: www_authenticate was added as the first argument, ahead of description.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
code = 401
description = The server could not verify that you are authorized to access the URL requested. You either...
get_headers(self, environ=None)

Get a list of headers.

classmethod wrap(cls, exception, name=None)

Create an exception that is a subclass of the calling HTTP exception and the exception argument.

The first argument to the class will be passed to the wrapped exception, the rest to the HTTP exception. If e.args is not empty and e.show_exception is True, the wrapped exception message is added to the HTTP error description.

Changed in version 0.15.5: The show_exception attribute controls whether the description includes the wrapped exception message.

Changed in version 0.15.0: The description includes the wrapped exception message.

property name(self)

The status name.

get_description(self, environ=None)

Get the description.

get_body(self, environ=None)

Get the HTML body.

get_response(self, environ=None)

Get a response object. If one was passed to the exception it’s returned directly.

Parameters

environ – the optional environ for the request. This can be used to modify the response depending on how the request looked like.

Returns

a Response object or a subclass thereof.

__call__(self, environ, start_response)

Call the exception as WSGI application.

Parameters
  • environ – the WSGI environment.

  • start_response – the response callable provided by the WSGI server.

__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.OAuthResponseProblem(token_response, **kwargs)

Bases: OAuthProblem

401 Unauthorized

Raise if the user is not authorized to access a resource.

The www_authenticate argument should be used to set the WWW-Authenticate header. This is used for HTTP basic auth and other schemes. Use WWWAuthenticate to create correctly formatted values. Strictly speaking a 401 response is invalid if it doesn’t provide at least one value for this header, although real clients typically don’t care.

Parameters
  • description – Override the default message used for the body of the response.

  • www-authenticate – A single value, or list of values, for the WWW-Authenticate header.

Changed in version 0.15.3: If the www_authenticate argument is not set, the WWW-Authenticate header is not set.

Changed in version 0.15.3: The response argument was restored.

Changed in version 0.15.1: description was moved back as the first argument, restoring its previous position.

Changed in version 0.15.0: www_authenticate was added as the first argument, ahead of description.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
code = 401
description = The server could not verify that you are authorized to access the URL requested. You either...
get_headers(self, environ=None)

Get a list of headers.

classmethod wrap(cls, exception, name=None)

Create an exception that is a subclass of the calling HTTP exception and the exception argument.

The first argument to the class will be passed to the wrapped exception, the rest to the HTTP exception. If e.args is not empty and e.show_exception is True, the wrapped exception message is added to the HTTP error description.

Changed in version 0.15.5: The show_exception attribute controls whether the description includes the wrapped exception message.

Changed in version 0.15.0: The description includes the wrapped exception message.

property name(self)

The status name.

get_description(self, environ=None)

Get the description.

get_body(self, environ=None)

Get the HTML body.

get_response(self, environ=None)

Get a response object. If one was passed to the exception it’s returned directly.

Parameters

environ – the optional environ for the request. This can be used to modify the response depending on how the request looked like.

Returns

a Response object or a subclass thereof.

__call__(self, environ, start_response)

Call the exception as WSGI application.

Parameters
  • environ – the WSGI environment.

  • start_response – the response callable provided by the WSGI server.

__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.OAuthScopeProblem(token_scopes, required_scopes, **kwargs)

Bases: werkzeug.exceptions.Forbidden

403 Forbidden

Raise if the user doesn’t have the permission for the requested resource but was authenticated.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
code = 403
description = You don't have the permission to access the requested resource. It is either read-protected or...
classmethod wrap(cls, exception, name=None)

Create an exception that is a subclass of the calling HTTP exception and the exception argument.

The first argument to the class will be passed to the wrapped exception, the rest to the HTTP exception. If e.args is not empty and e.show_exception is True, the wrapped exception message is added to the HTTP error description.

Changed in version 0.15.5: The show_exception attribute controls whether the description includes the wrapped exception message.

Changed in version 0.15.0: The description includes the wrapped exception message.

property name(self)

The status name.

get_description(self, environ=None)

Get the description.

get_body(self, environ=None)

Get the HTML body.

get_headers(self, environ=None)

Get a list of headers.

get_response(self, environ=None)

Get a response object. If one was passed to the exception it’s returned directly.

Parameters

environ – the optional environ for the request. This can be used to modify the response depending on how the request looked like.

Returns

a Response object or a subclass thereof.

__call__(self, environ, start_response)

Call the exception as WSGI application.

Parameters
  • environ – the WSGI environment.

  • start_response – the response callable provided by the WSGI server.

__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception connexion.exceptions.ExtraParameterProblem(formdata_parameters, query_parameters, title=None, detail=None, **kwargs)

Bases: ProblemException

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.