Skip to main content
Skip table of contents

User Defined Error Responses

User Defined Error Responses

To return an error response as the output of an endpoint cell with a particular HTTP status code, the notebook cell should return a dictionary with a status key and HTTP status code as its value, as well as an error object containing a name with the desired exception name and a message key with the desired error message.

CODE
response = { 'status': 400, 'error': {'name': 'MyException','message': 'Could not compute'}}
response

Alternatively, the endpoint code can raise an exception and Data Lab Functions will compose the error response. However, the HTTP status would be 500.

HTTP status codes 502, 503, and 504 are reserved and cannot be used in user-defined error responses.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.