What do you use for error checking?

Do you use exceptions, or asserts? Error logs...
Looking for a new way to catch errors, currently use assert(). Hoping to find something better.
A combination of asserts and exceptions.

asserts are supposed to be conditions that you want to check in a development build only, and should be
compiled out for releases. asserts() abort the program ungracefully, which is probably not what you want your
users to see.

exceptions should be used to handle unexpected errors. An unexpected error might be running
out of disk space when the output file is half written. The user entering "apple" when you ask them for their
age is not an unexpected error. Exceptions are also useful when you need to report an error to a higher
level, but cannot do so through return codes. This happens, for example, if an error occurs in operator
functions (+, -, [], etc, where the signature of the function is largely predetermined). It also happens if you
encounter an error in deeply nested template land, such as deserializing a buffer using boost::serialization
or parsing user input using boost::spirit.
Topic archived. No new replies allowed.