Error Handling

Functions for reporting fatal and non-fatal programmer errors.

Defines

rs_assert(val)

Assert that something is true.

Use this for internal-consistancy checks ONLY, and do NOT use it to check stuff that comes from the outside world. These can be compiled out, so don’t use it for checks you always want!

For something equivalent to use on user-provided data, use rs_critical(), rs_error(), and the rs_return_* family of functions.

See also

rs_critical, rs_error

See also

rs_return_if_fail, rs_return_val_if_fail

See also

rs_return_if_reached, rs_return_val_if_reached

Parameters:
  • val – the truth value to check

rs_critical(...)

printf-like error logger, non-fatal

Use this when the program is not currently crashing, but will likely fail in the future because of some very unexpected error. An example would be getting a NULL pointer as the ‘self’ parameter. All the rs_return_* variants use this; you should use those if the default error message is sufficient.

For a fatal version, see rs_error().

See also

rs_error

See also

rs_return_if_fail, rs_return_val_if_fail

See also

rs_return_if_reached, rs_return_val_if_reached

rs_error(...)

printf-like error logger, fatal

Use this when a program has hit a dead end, and nothing can be done to salvage it. These should be rare because they cause an immediate exit.

For a non-fatal version, see rs_critical().

See also

rs_critical

rs_return_if_fail(test)

A weaker rs_assert() for external bugs.

Use this instead of rs_assert() for programming errors originating outside of libredstone. It will return immediately from the calling function if the test fails, and print out an informative message via rs_critical. This will not exit the program; however, after a call to this function, the program may be in a dangerous state.

If you need to return a value, use rs_return_val_if_fail().

See also

rs_critical

See also

rs_return_val_if_fail

See also

rs_return_if_reached, rs_return_val_if_reached

Parameters:
  • test – the truth value to check

rs_return_val_if_fail(test, val)

A weaker rs_assert() for external bugs (with value).

Use this instead of rs_assert() for programming errors originating outside of libredstone. It will return immediately from the calling function if the test fails, and print out an informative message via rs_critical. This will not exit the program; however, after a call to this function, the program may be in a dangerous state.

If you don’t need to return a value, use rs_return_if_fail().

See also

rs_critical

See also

rs_return_if_fail

See also

rs_return_if_reached, rs_return_val_if_reached

Parameters:
  • test – the truth value to check

  • val – the value to return

rs_return_if_reached()

A weaker rs_assert(false) for external bugs.

Use this instead of rs_assert() for programming errors originating outside of libredstone. It will return immediately from the calling function, and print out an informative message via rs_critical. This will not exit the program; however, after a call to this function, the program may be in a dangerous state.

If you need to return a value, use rs_return_val_if_reached().

See also

rs_critical

See also

rs_return_if_fail, rs_return_val_if_fail

See also

rs_return_val_if_reached

rs_return_val_if_reached(val)

A weaker rs_assert(false) for external bugs (with value).

Use this instead of rs_assert() for programming errors originating outside of libredstone. It will return immediately from the calling function, and print out an informative message via rs_critical. This will not exit the program; however, after a call to this function, the program may be in a dangerous state.

If you don’t need to return a value, use rs_return_if_reached().

See also

rs_critical

See also

rs_return_if_fail, rs_return_val_if_fail

See also

rs_return_if_reached

Parameters:
  • val – the value to return

Functions

void _rs_error_log(bool error, const char *filename, unsigned int line, const char *func, const char *str, ...)

Internal log function, don’t use!