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 code field.
string or code node code
A comparison string or a node from mux.error.codes or mux.error.namespace. Plain strings are used verbatim; this function does not validate their syntax.

Returns

boolean matches
true when value.code equals code or begins with code followed by a dotted segment; otherwise false.

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.

See Also