Yandex Cloud
Documentation
PresentationContact UsTry it for free
© 2026 Direct Cursus Technology L.L.C.
Yandex Cloud Functions
  • Comparing with other Yandex Cloud services
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Error handling
    • Using the SDK
  • Tools
  • Pricing policy
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes
  • FAQ
  1. Developing in Python
  2. Error handling

Python function error handling

Written by
Yandex Cloud
Updated at July 2, 2026
View as Markdown

If the handler reports a Python function execution or loading error, the runtime automatically catches the error and returns a JSON document with details of the error type, text, and location. For more information about the JSON document format, see Invoking a function.

The error info is also written to the execution log. You can view the log via the Yandex Cloud CLI or the management console.

Example of error handlingExample of error handling

Function code:

def handler(event, context):
    return unknownVariable

JSON document returned:

{
    "errorMessage": "name 'unknownVariable' is not defined",
    "errorType": "NameError",
    "stackTrace": [
        "  File \"/function/runtime/runtime.py\", line 155, in handle_event\n    result = h(r.event, r.context)\n",
        "  File \"/function/code/main.py\", line 2, in handler\n    return unknownVariable\n"
    ]
}

Was the article helpful?

Previous
Logging
Next
Using the SDK
© 2026 Direct Cursus Technology L.L.C.