docs: fix exception-handling examples and Lua.new option doctests#387
Merged
Conversation
The README error-handling tour read `e.message`, but the wrapper leaves that field nil when it wraps a VM exception (since #384); the message is rendered lazily via `Exception.message/1`. Switch the example to the accessor and correct the illustrative frame — the formatter emits location-then-body, with no "Runtime Error" title line. Re-indent the three Lua.new/1 `## Options` doctests from 6 to 8 spaces so ExDoc renders them as code blocks inside the bullet list rather than plain continuation paragraphs, and drop the double-escaped \"x\" in favour of a single-quoted Lua string so it renders cleanly. Fix the marketing snippets: `Lua.eval/2` does not exist (only eval!/2), and the sandbox snippet read the nil `.message` field with the wrong expected text.
davydog187
commented
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes three classes of documentation mistake around exception handling and doctest rendering. All examples were verified by running them.
1. README:
e.messagereturnsnilThe "Error messages with source and line" tour rescued a
Lua.RuntimeExceptionfromerror("...")and reade.message. Since #384, that field isnilwhen the exception wraps a VM error — the message is rendered lazily viaException.message/1. Switched the example to the accessor.The illustrative comment was also wrong: it showed a
Runtime Errortitle line the formatter never emits. Corrected to the actual (ANSI-elided) frame:e.line/e.sourcewere already correct and are unchanged.2.
Lua.new/1option doctests rendered as plain textThe three
## Optionsdoctests (:max_call_depth,:max_string_bytes,:max_instructions) were indented 6 spaces. Nested under 2-space bullets, a code block needs 8 spaces — so Markdown/ExDoc rendered them as lazy continuation paragraphs instead of highlighted code blocks. Re-indented all three (confirmed viamix docsthat each now renders inside a<pre>block within its bullet).Also replaced the double-escaped
\"x\"in the:max_string_bytesexample with a single-quoted Lua string ('x') so it renders cleanly.3. Marketing snippets used a function that doesn't exist
website/.../snippets.excalledLua.eval/2(onlyLua.eval!/2exists) in three places, and the sandbox snippet read the nil.messagefield with the wrong expected substring. Rewrote to idiomaticLua.eval!/2(correct{results, lua}shape; the sandbox one now shows the raise, matchingos.execute(_) is sandboxed).Verification
mix test --only doctest— 49 pass (the three re-indentedLua.new/1doctests included).mix docs— the three option examples now render as code blocks;\"x\"escaping gone.mix format --check-formatted lib/lua.ex— clean.