From 22cb42c51fcf1ff388455e0e7bd42266aa3ef1e3 Mon Sep 17 00:00:00 2001 From: "Bob (Clawdbot)" Date: Thu, 12 Mar 2026 07:37:58 +0100 Subject: [PATCH] fix(error-handling): use correct SDK API classes gl.UserError and gl.user_error_immediate do not exist in the SDK. The correct classes per genlayer.gl module source are: - gl.vm.UserError (genlayer.gl.vm.UserError) - gl.advanced.user_error_immediate (genlayer.gl.advanced.user_error_immediate) Verified against SDK API reference at sdk.genlayer.com/main/api/genlayer.html and production intelligent contracts using these APIs successfully. --- .../features/error-handling.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pages/developers/intelligent-contracts/features/error-handling.mdx b/pages/developers/intelligent-contracts/features/error-handling.mdx index 34453f20..2ea56948 100644 --- a/pages/developers/intelligent-contracts/features/error-handling.mdx +++ b/pages/developers/intelligent-contracts/features/error-handling.mdx @@ -21,10 +21,10 @@ User-generated errors with UTF-8 encoded messages: ```python # Can be caught in current sub-vm -raise gl.UserError("Invalid input") +raise gl.vm.UserError("Invalid input") # Immediate user error, more efficient but can't be caught -gl.user_error_immediate("Insufficient funds") +gl.advanced.user_error_immediate("Insufficient funds") ``` ## VMError @@ -45,11 +45,11 @@ Handle user errors from sub-VMs: ```python def risky_operation(): - raise gl.UserError("Operation failed") + raise gl.vm.UserError("Operation failed") try: result = gl.eq_principle.strict_eq(risky_operation) -except gl.UserError as e: +except gl.vm.UserError as e: print(f"Caught user error: {e.message}") ``` @@ -60,12 +60,12 @@ Errors flow from non-deterministic to deterministic code: ```python def nondet_block(): if some_condition: - raise gl.UserError("INVALID_STATE") + raise gl.vm.UserError("INVALID_STATE") return "success" try: gl.eq_principle.strict_eq(nondet_block) -except gl.UserError as e: +except gl.vm.UserError as e: if e.message == "INVALID_STATE": # Handle specific error condition pass