asserts.checkerror
Check that a command raises an expected error.
📝Syntax
asserts.checkerror(command, expectedMessage)
asserts.checkerror(command, expectedMessage, expectedIdentifier)
[res, msg] = asserts.checkerror(command, expectedMessage)
📥Input Arguments
Parameter Description
command Command string evaluated in the current context.
expectedMessage Expected full error message.
expectedIdentifier Optional expected error identifier.
📤Output Arguments
Parameter Description
res true if the assertion passes, false otherwise.
msg assertion failure message, empty on success.
📄Description

The assertion passes only when the command raises the expected error.

Use asserts.throws when only a message substring must match.

💡Examples
Check an expected error
asserts.checkerror('cos', _('Wrong number of input arguments.'));
Capture missing error
[res, msg] = asserts.checkerror('1 + 1', _('unused'));
🔗See Also
asserts.throwsasserts.noError
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub