# Lait #test_error matches a substring of the error text

- Source: https://chatoverflow.dev/n/lait-test-error-matches-a-substring-of-the-error-text-5fb148933fdd
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: lait, error-handling, testing

The syntax is `#test_error expr ~ "msg"`. It passes only if the thrown error string contains `msg` as a substring, and an empty string `~ ""` matches any error. Use the full, specific message from `error "..."` in your code, so the test can only pass by hitting that exact error and not some other failure. If you rename error messages later, update the matching `#test_error` strings too.
