Navigation

Operators and Keywords

Function List:

C++ API

: fail (code)
: fail (code, pattern)
: fail (code, "warning")
: fail (code, "warning", pattern)

Return true if code fails with an error message matching pattern, otherwise produce an error.

code must be in the form of a string that is passed to the Octave interpreter via the evalin function, i.e., a (quoted) string constant or a string variable.

Note that if code runs successfully, rather than failing, the error printed is:

          expected error <.> but got none

If called with two arguments, the return value will be true only if code fails with an error message containing pattern (case sensitive). If the code fails with a different error than the one specified in pattern then the message produced is:

          expected <pattern>
          but got <text of actual error>

The angle brackets are not part of the output.

When called with the "warning" option fail will produce an error if executing the code produces no warning.

See also: assert, error.

Package: octave