If an apiFunction handler raises this exception, the server will use hwebserver.errorResponse to generate a 422 Unprocessable Entity response with a JSON Object body containing an error key with the given error message.
Any other kind of exception in a handler function will generate a generic 500 Internal Server Error. If the server is running in debug mode, the response body will contain a stack trace.
Note
webapiclient.py also has an APIError exception class.
If an API function raises an APIError exception from the server,
webapiclient will also raise an APIError from the client. If an
API function on the server raises another exception and returns 500,
webapiclient will also raise APIerror with the contents of the 500
response. You can access api_error.status_code from the client to
differentiate between 422 and 500 errors.
Methods ¶
__init__(msg)
You can supply an error message string or any JSON-encodable object as the “message”. Assuming the client indicated it accepts JSON, the response will be JSON where the body is a JSON Object with an error key containing the error message.