is
Tests whether an error-like value has a matching code.
Function
Synopsis
mux.error.is(value, code)
Arguments
any value- A value to inspect. It matches only when it is a table with a string
codefield. string or code node code- A comparison string or a node from
mux.error.codesormux.error.namespace. Plain strings are used verbatim; this function does not validate their syntax.
Returns
boolean matchestruewhenvalue.codeequalscodeor begins withcodefollowed by a dotted segment; otherwisefalse.
Examples
if mux.error.is(err, mux.error.codes.state) then
-- Matches mux.state.invalid, mux.state.unavailable, and related leaves.
end
Notes
Error:is is the equivalent method on an Error. Prefix
matching stops at segment boundaries, so mux.state does not match
mux.statement.invalid. Prefer checked code nodes when possible; malformed
plain strings simply participate in the same exact-or-prefix comparison.