Error handling¶
-
exception
pyrs.resource.errors.
BadRequestError
(message=None, errors=None, **details)[source]¶ Bases:
pyrs.resource.errors.ClientError
Request cannot be processed because of an error.
-
error
= 'BadRequest'¶
-
schema
¶ alias of
BadRequestErrorSchema
-
-
class
pyrs.resource.errors.
BadRequestErrorSchema
(extend=None, **attrs)[source]¶ Bases:
pyrs.resource.errors.ErrorSchema
-
_attrs
= OrderedDict([('additional', False)])¶
-
_definitions
= None¶
-
_fields
= OrderedDict([('error', <pyrs.schema.types.String object at 0x7f602ecb3518>), ('error_description', <pyrs.schema.types.String object at 0x7f602ecb3550>), ('error_uri', <pyrs.schema.types.String object at 0x7f602ecb3588>), ('message', <pyrs.schema.types.String object at 0x7f602ecb35c0>), ('details', <pyrs.resource.errors.DetailsSchema object at 0x7f602ecb35f8>), ('errors', <pyrs.schema.types.Array object at 0x7f602ecb3748>)])¶
-
-
exception
pyrs.resource.errors.
ClientError
(*args, **details)[source]¶ Bases:
pyrs.resource.errors.Error
Generic Client Error. Normally the client errors have 4xx status codes.
-
status
= 400¶
-
-
class
pyrs.resource.errors.
DetailsSchema
(extend=None, **attrs)[source]¶ Bases:
pyrs.schema.types.Object
Details part of the error schema. Additional properties possible.
-
_attrs
= OrderedDict([('additional', True)])¶
-
_definitions
= None¶
-
_fields
= OrderedDict([('traceback', <pyrs.schema.types.Array object at 0x7f602ecb3358>), ('args', <pyrs.schema.types.Array object at 0x7f602ecb3470>)])¶
-
-
exception
pyrs.resource.errors.
Error
(*args, **details)[source]¶ Bases:
Exception
This is the base exception of this framework. The response based on this exception will be a JSON data
-
description
= None¶ Description of error. Should give details about the error In the message it will appearing as error_description
-
details
= None¶ None used as empty dict. Gives extra information about this error which could be parsed by the consumer of API.
-
error
= None¶ Error code should be a string. If it’s not specified the class fully qualified name will be used
-
get_details
(debug=False)[source]¶ Gives back detailed information about the error and the context. As this is part of the message should conform with the DetailsSchema.
-
get_headers
()[source]¶ This method gives back the header property by default or an empty dict, but you can override, then provide special headers based on the context
-
get_status
()[source]¶ This method gives back the status property by default which will be threated as HTTP status code. You can override, then provide your own status code based on the context.
-
headers
= None¶ HTTP Response headers, (default None processed as empty)
-
schema
¶ You can specify your schema class for validating your message By default the application default error schema the ErrorSchema will be used
alias of
ErrorSchema
-
status
= 500¶ HTTP status code (default=500)
-
uri
= None¶ Reference for this error. You can pointing out a documentation which gives more information about how could this error happen and how could be possible to avoid
-
-
class
pyrs.resource.errors.
ErrorSchema
(extend=None, **attrs)[source]¶ Bases:
pyrs.schema.types.Object
Describe how the error response should look like. Goal of this schema is a minimalistic but usable error response.
-
_attrs
= OrderedDict([('additional', False)])¶
-
_definitions
= None¶
-
_fields
= OrderedDict([('error', <pyrs.schema.types.String object at 0x7f602ecb3518>), ('error_description', <pyrs.schema.types.String object at 0x7f602ecb3550>), ('error_uri', <pyrs.schema.types.String object at 0x7f602ecb3588>), ('message', <pyrs.schema.types.String object at 0x7f602ecb35c0>), ('details', <pyrs.resource.errors.DetailsSchema object at 0x7f602ecb35f8>)])¶
-
get_details
(ex)[source]¶ Gives back detailed information about the error and the context. By default its an empty dictionary. The debug depends on the debug parameter should give back traceback information and the positional arguments of the exception. As this is part of the message should conform with the ErrorSchema.
-
-
exception
pyrs.resource.errors.
InternalServerError
(*args, **details)[source]¶ Bases:
pyrs.resource.errors.Error
-
error
= 'InternalServerError'¶
-
status
= 500¶
-
-
exception
pyrs.resource.errors.
NotFound
(*args, **details)[source]¶ Bases:
pyrs.resource.errors.ClientError
-
error
= 'NotFound'¶
-
status
= 404¶
-