Skip to content

docs(contracts): use gl.vm.UserError, gl.UserError does not exist - #516

Open
kriss39 wants to merge 1 commit into
genlayerlabs:mainfrom
kriss39:fix/gl-vm-usererror
Open

docs(contracts): use gl.vm.UserError, gl.UserError does not exist#516
kriss39 wants to merge 1 commit into
genlayerlabs:mainfrom
kriss39:fix/gl-vm-usererror

Conversation

@kriss39

@kriss39 kriss39 commented Sep 14, 2026

Copy link
Copy Markdown

What

Seven snippets across three pages raise gl.UserError(...) / except gl.UserError. Neither GenVM std library exports UserError at the gl level — the class is gl.vm.UserError:

  • v0.2 (the runner these pages pin): genlayer/gl/__init__.py has no UserError in __all__, and its lazy __getattr__ raises AttributeError: module 'genlayer.gl' has no attribute 'UserError'; the class is genlayer/gl/vm.py.
  • v0.3: genlayer/__init__.py likewise; the class is genlayer/vm/__init__.py:156.

error-handling.mdx already uses gl.vm.UserError correctly in its other snippets (lines 30, 54, 58, 69, 74), so this only makes the remaining seven lines consistent.

Copying any of these snippets into a contract turns the intended UserError (a recoverable contract error) into an AttributeError on the raise line itself, i.e. an unrecoverable VM exit.

Change

  • pages/developers/intelligent-contracts/features/calling-llms.mdx (4 lines)
  • pages/developers/intelligent-contracts/features/web-access.mdx (2 lines)
  • pages/developers/intelligent-contracts/features/error-handling.mdx (1 line)

s/gl\.UserError/gl.vm.UserError/ only; no other edits.

Verification

  • Attribute probe against both std versions with GENERATING_DOCS=true: gl.UserErrorAttributeError, gl.vm.UserError → OK (v0.2.16 and v0.3.x).
  • python3 scripts/lint-code-examples.py: all 99 snippets still parse; the 24 reported issues are identical to main (pre-existing, unrelated pages).
  • grep -rn "gl\.UserError" pages → 0 after the change.

Note: open PR #423 (ContractRollback → UserError) introduces the same gl.UserError spelling in api-references/genlayer-test/direct.md; it would want the gl.vm. prefix too.

Summary by CodeRabbit

  • Documentation
    • Updated Python examples to use the current gl.vm.UserError syntax.
    • Corrected error-handling examples for LLM responses, consensus validation, and HTTP client/server errors.

@netlify

netlify Bot commented Sep 14, 2026

Copy link
Copy Markdown

Deploy Preview for genlayer-docs ready!

Name Link
🔨 Latest commit d25f82e
🔍 Latest deploy log https://app.netlify.com/projects/genlayer-docs/deploys/6aa7c01b5723230008432443
😎 Deploy Preview https://deploy-preview-516--genlayer-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 45b6480b-c98b-43b5-9442-440b431ced11

📥 Commits

Reviewing files that changed from the base of the PR and between 1cd8e2d and d25f82e.

📒 Files selected for processing (3)
  • pages/developers/intelligent-contracts/features/calling-llms.mdx
  • pages/developers/intelligent-contracts/features/error-handling.mdx
  • pages/developers/intelligent-contracts/features/web-access.mdx

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The documentation updates Python examples to use gl.vm.UserError for error raising and catching across LLM, consensus, and web-access examples.

Changes

Error namespace documentation

Layer / File(s) Summary
Update UserError references
pages/developers/intelligent-contracts/features/calling-llms.mdx, pages/developers/intelligent-contracts/features/error-handling.mdx, pages/developers/intelligent-contracts/features/web-access.mdx
Replaced gl.UserError with gl.vm.UserError in error-raising and error-catching examples.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to d25f8

The examples now reference the correct error namespace, with no concrete merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the Conventional Commits format and clearly identifies the documentation fix: replacing the nonexistent gl.UserError with gl.vm.UserError.
Description check ✅ Passed The description clearly explains the issue, lists all affected files, states the exact change, and provides verification results. It does not use the template's exact ## Description heading, but it pr…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant