Clone wiki

pngxx / errors

Exceptions and error handling

jpegxx and pngxx use exeptions to report errors.

For detailed information about each exception type, you should look at the <jpegxx/exceptions.hpp> and <pngxx/exceptions.hpp> headers, where each exception class is documented in doxygen markup. In addition, all of the public functions of the libraries are similarly documented and each specifies the particular exceptions that may be thrown.

Some exceptions contain extra data members to the classes from which they inherit, in order to provide more accurate diagnostics at the catch site.

Except for imagexx::exception, pngxx::exception and jpegxx::exception, all exception classes inherit from a C++ standard library exception. Therefore, a catch clause that catches std::exception objects will also catch exceptions thrown by pngxx and jpegxx.

The imagexx, jpegxx and pngxx exceptions hierarchy is pictured below. Ignore the auto_exception_impl<> stuff -- that's merely an implementation detail that I am too lazy to delete from the dot file created by doxygen!.

The imagexx, jpegxx and pngxx exceptions hierarchy

Exception safety

I have designed pngxx and jpegxx to provide the strongest exception safety guarantees possible, without sacrificing efficiency.

Obviously, reading and writing images is a side effect of using the library and I can't unwind uni-directional iterators or undo state changes to objects passed to the library. But the jpegxx and pngxx objects and functions will never leak resources.