Foobar2000:Development:Exceptions

From Hydrogenaudio Knowledgebase


Exception use

Most of API functions use C++ exceptions to signal failure conditions. All used exception classes must derive from std::exception; this design allows various instances of code to use single catch() line to obtain human-readable description of the problem to display.

Additionally, special subclasses of exceptions are defined for use in specific conditions, such as exception_io for I/O failures. As a result, you must provide an exception handler whenever you invoke any kind of I/O code that may fail, unless in specific case calling context already handles exceptions (e.g. input implementation code - any exceptions should be forwarded to calling context, since exceptions are a part of input API).

Implementations of global callback services such as playlist_callback, playback_callback or library_callback must not throw unhandled exceptions; behaviors in case they do are undefined (app termination is to be expected).