oclaw/openclaw/extensions/open-prose/skills/prose/examples/22-error-handling.prose
oliver dbbe3add6a 重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。

Made-with: Cursor
2026-04-26 08:34:33 +08:00

51 lines
1.3 KiB
Text

# Error Handling Example
# Demonstrates try/catch/finally patterns for resilient workflows
# Basic try/catch for error recovery
try:
session "Attempt to fetch data from external API"
catch:
session "API failed - use cached data instead"
# Catch with error variable for context-aware handling
try:
session "Parse and validate complex configuration file"
catch as err:
session "Handle the configuration error"
context: err
# Try/catch/finally for resource cleanup
try:
session "Open database connection and perform queries"
catch:
session "Log database error and notify admin"
finally:
session "Ensure database connection is properly closed"
# Nested error handling
try:
session "Start outer transaction"
try:
session "Perform risky inner operation"
catch:
session "Recover inner operation"
throw # Re-raise to outer handler
catch:
session "Handle re-raised error at outer level"
# Error handling in parallel blocks
parallel:
try:
session "Service A - might fail"
catch:
session "Fallback for Service A"
try:
session "Service B - might fail"
catch:
session "Fallback for Service B"
session "Continue with whatever results we got"
# Throwing custom errors
session "Validate input data"
throw "Validation failed: missing required fields"