Library Exceptions

Library-specific Exception classes. Provides clients with more granular exception handling facilities, allowing a clearer response to specific internal or external (network) failures.

Server Exceptions

The following exceptions are thrown by the urest.http.server.RESTServer class, and should be handled by the API server and not passed directly onto the network client.

urest.http.server.RESTClientError

Bases: Exception

Client Error. Thrown as a general failure of client requests, usually as a result of transient network errors.

This exception should be notified to the client as the HTTP response ‘400 Bad Request’, and further processing should not be attempted until the client retries the request.

Source code in urest/http/server.py
89
90
91
92
93
94
95
96
97
98
class RESTClientError(Exception):
    """Client Error. Thrown as a general failure of client requests, usually as
    a result of transient network errors.

    This exception should be notified to the client as the HTTP response
    '`400 Bad Request`', and further processing should not be attempted
    until the client retries the request.
    """

    pass

urest.http.server.RESTServerError

Bases: Exception

Internal Server Error. Thrown as a general failure of the urest.http.server module when no more specific exception is available. This usually indicates a bug in the library.

This exception should be notified to the client as the HTTP response ‘500 Internal Server Error’, and further processing should not be attempted.

Source code in urest/http/server.py
101
102
103
104
105
106
107
108
109
110
111
class RESTServerError(Exception):
    """Internal Server Error. Thrown as a general failure of the
    `urest.http.server` module when no more specific exception is available.
    This usually indicates a bug in the library.

    This exception should be notified to the client as the HTTP response
    '`500 Internal Server Error`', and further processing should not be
    attempted.
    """

    pass

urest.http.server.RESTParseError

Bases: Exception

Parse failure. The HTTP header or body elements supplied by the network client are invalid, and cannot be parsed correctly by the urest.http.server module.

This exception should be notified to the client as the HTTP response ‘400 Bad Request’, and further processing should not be attempted until the client retries the request.

Source code in urest/http/server.py
114
115
116
117
118
119
120
121
122
123
124
class RESTParseError(Exception):
    """Parse failure. The HTTP header or body elements supplied by the network
    client are invalid, and cannot be parsed correctly by the
    `urest.http.server` module.

    This exception should be notified to the client as the HTTP response
    '`400 Bad Request`', and further processing should not be attempted
    until the client retries the request.
    """

    pass

Network Helper Exceptions

The following exceptions arise from the [urest.utils][urest.utils] module. Unless the classes and functions within the [urest.utils][urest.utils] module are being used, these can be ignored as they should not be generated by the core library modules.

urest.utils.network_connect.WirelessNetworkError

Bases: Exception

General Wireless Network Exception. Thrown in response to one of the codes listed in the module Attributes, and originating from the underlying C library.

The message of the the Exception is set to an appropriate response, and it should be assumed that the text of the Exception will be passed back to the user. Therefore it is important that the message aids further debugging without having to consult the underlying library documentation.

Source code in urest/utils/network_connect.py
119
120
121
122
123
124
125
126
127
128
129
130
131
class WirelessNetworkError(Exception):
    """General Wireless Network Exception. Thrown in response to one of the
    codes listed in the module `Attributes`, and originating from the
    underlying C library.

    The message of the the `Exception` is set to an appropriate
    response, and it should be assumed that the text of the `Exception`
    will be passed back to the user. Therefore it is important that the
    message aids further debugging without having to consult the
    underlying library documentation.
    """

    pass