![]()
|
Inherited by CImgArgumentException, CImgDisplayException, CImgInstanceException, CImgIOException, and CImgWarningException.
Public Attributes | |
char | message [1024] |
Message associated with the error that thrown the exception. |
CImg<float> img; // Construct an empty image. img.blur(10); // Try to blur the image.
CImg<float> img(100,100,1,3); // Define a 100x100 color image with float pixels. img = 0; // Try to fill pixels from the 0 pointer (invalid argument to operator=() ).
CImg<float> img("file_doesnt_exist.jpg"); // Try to load a file that doesn't exist.
The parent class CImgException may be thrown itself when errors that cannot be classified in one of the above type occur. It is recommended not to throw CImgExceptions yourself, since there are normally reserved to CImg Library functions. CImgInstanceException, CImgArgumentException, CImgIOException and CImgDisplayException are simple subclasses of CImgException and are thus not detailled more in this reference documentation.
try { ... } catch() { ... }
. In this case, you can avoid the apparition of the modal window, by defining the environment variable cimg_debug
to 0 before including the CImg header file. The example below shows how to cleanly handle CImg Library exceptions : #define cimg_debug 0 // Disable modal window in CImg exceptions. #define "CImg.h" int main() { try { ...; // Here, do what you want. } catch (CImgInstanceException &e) { std::fprintf(stderr,"CImg Library Error : %s",e.message); // Display your own error message ... // Do what you want now. } }