Raise errors Stay organized with collections Save and categorize content based on your preferences.
You can raise custom errors using theraise syntax, and you can catch andhandle errors using atry/except block.
Errors can be either a string or a map. You can use user-defined keys:
YAML
-STEP_NAME:raise:KEY_1:VALUE_1KEY_2:VALUE_2
JSON
[{"STEP_NAME":{"raise":{"KEY_1":"VALUE_1","KEY_2":"VALUE_2"}}}]
Examples
String
YAML
-step_a:raise:"Somethingwentwrong."
JSON
[{"step_a":{"raise":"Something went wrong."}}]
Map
YAML
-step_a:raise:code:55message:"Somethingwentwrong."
JSON
[{"step_a":{"raise":{"code":55,"message":"Something went wrong."}}}]
What's next
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.