When a Python function throws an unhandled exception during function execution, Function Compute captures it and returns a structured error response to the caller.
How it works
Function Compute intercepts the unhandled exception before it reaches the caller. The presence of an error is signaled by the X-Fc-Error-Type: UnhandledInvocationError HTTP header.
The HTTP response body contains the error details in JSON:
def my_handler(event, context):
raise Exception('something is wrong'){
"errorMessage": "something is wrong",
"errorType": "Exception",
"stackTrace": [
[
"File \"/code/index.py\"",
"line 2",
"in my_handler",
"raise Exception('something is wrong')"
]
]
}Error response fields
| Field | Type | Description |
|---|---|---|
errorMessage | String | The exception message passed when the exception was raised. |
errorType | String | The error type. |
stackTrace | List | The error stack. |
What's next
For a complete list of error types returned by Function Compute, see Error handling.