All Products
Search
Document Center

Function Compute:Error handling

Last Updated:Mar 31, 2026

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

FieldTypeDescription
errorMessageStringThe exception message passed when the exception was raised.
errorTypeStringThe error type.
stackTraceListThe error stack.

What's next

  • For a complete list of error types returned by Function Compute, see Error handling.