Skip to content

Errors ​

FURY never returns a wrong number: an operation on inconsistent units prints an error on the standard error and stops the program with error stop, exit status 1, so that a script or a batch system sees the failure.

Messages ​

MessageRaised by
cannot add "A" and "B"+ of quantities or units with different units
cannot subtract "B" from "A"- of quantities or units with different units
cannot assign "B" to "A"= of a quantity or a unit to one that has a different unit; unset it first
cannot convert "A" to "B"qreal%to between units that no formula relates
cannot raise "A" to x: the exponent would not be an integera real power giving a non-integer exponent, e.g. m ** 0.5
cannot parse "D": the exponent of the dimensions "d" differs from the one of the symbol "s"a definition like Hz = s-1 [time-2]
cannot parse "D": the main alias must be one "(...)"a definition with more than one main alias
cannot parse "D": the name must be one "{...}"a definition with more than one name
cannot parse "D": a symbol cannot have a null multiplicative factoran alias like 0 * m

A and B are the operands, printed with their dimensions.

$ tutorial_4 add
error: cannot add "+3.0 m [length]" and "+2.0 s [time]"
[exit status 1]
$ tutorial_5 impossible
error: cannot convert "m [length]" to "s [time]"
[exit status 1]

Handling an impossible conversion ​

A program that must go on when a conversion does not exist uses uom%convert, which reports the outcome instead of stopping (see Conversions). A unit not found in a units system is returned undefined: check it with is_defined().

Testing the errors ​

The tests of FURY named fury_test_xfail_* check that each inconsistency stops the program: scripts/run_tests.sh counts them as passed when they exit with a non-zero status.

Released under GPL v3, BSD 2-Clause, BSD 3-Clause or MIT, at your choice.