Skip to content

docs: add error_matches example to README#204

Merged
Tieske merged 3 commits into
masterfrom
copilot/add-readme-example-error-matches
May 29, 2026
Merged

docs: add error_matches example to README#204
Tieske merged 3 commits into
masterfrom
copilot/add-readme-example-error-matches

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

The top-level example block in the README was missing a demonstration of assert.error_matches, leaving it undocumented alongside the other quick-start assertions.

Changes

  • README.md: Added one line to the existing top example block showing assert.error_matches with a function that throws an error and a pattern that matches part of the message:
assert.error_matches(function() error("foo bar") end, "foo")
Original prompt

Add a README example for the error_matches assertion in the repository lunarmodules/luassert.

Context:

  • The user wants a pull request, not just an explanation.
  • The relevant assertion implementation is in src/assertions.lua.
  • error_matches(state, arguments, level) works by:
    • expecting at least two arguments: a callable and a string pattern;
    • executing the callable with pcall(func);
    • if the callable does not error, the assertion fails;
    • if the error value is a string, it strips any leading path/to/file:line: prefix;
    • it optionally accepts an error message plus init and plain arguments similar to string.match / string.find behavior;
    • if plain is truthy, it checks err_actual:find(pattern, init, plain) ~= nil;
    • otherwise it checks err_actual:match(pattern, init) ~= nil.

Task:

  • Update the README to add a concise example near the top where the README currently lists a few examples.
  • The example should demonstrate using assert.error_matches(...) with a function that throws an error and a pattern that matches part of the error message.
  • Keep the style consistent with the existing README examples.
  • Avoid broad documentation rewrites; make the smallest clear addition needed.
  • Create a pull request with the change.

Repository: lunarmodules/luassert
Base branch: master

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: how does the error_matches assertion work? create a PR to add an example to the readme (at the top there is a list of a few examples)

Assistant: I’m waiting for your confirmation on the pull request creation step—once you approve it, I’ll continue.

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Add README example for error_matches assertion docs: add error_matches example to README May 29, 2026
Copilot finished work on behalf of Tieske May 29, 2026 06:21
Copilot AI requested a review from Tieske May 29, 2026 06:21
Comment thread README.md Outdated
@Tieske Tieske marked this pull request as ready for review May 29, 2026 06:37
@Tieske Tieske merged commit 8e18d95 into master May 29, 2026
5 of 15 checks passed
@Tieske Tieske deleted the copilot/add-readme-example-error-matches branch May 29, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants