-1

The code below catches not only errors but also some warnings with some specific inputs. Is there any way to ignore all the warnings instead of checking them in the catch block? I know I can use +profile "*" on terminal, but I have no idea about what to tackle it in C++.

try {
    Blob buff = Blob(input, inLen);
    pImage->read(buff);
} catch (Exception &error) {
    cout << error.what() << endl;
    delete(pImage);
    return -1;
}
Pittie
  • 191
  • 1
  • 13
  • Warnings are not exception, so you can't catch them. You can edit ImageMagick's `log.xml` configuration file to redirect warnings to a file, or perhaps disable them. – emcconville Jul 10 '19 at 12:54
  • I've seen this message in the catch block `Magick: Invalid cHRM red point () reported by coders/png.c:1106 (PNGWarningHandler)`. isn't it a warning? – Pittie Jul 11 '19 at 02:13
  • Ah. Perhaps I'm wrong. I'll post an possible solution. – emcconville Jul 11 '19 at 12:24

1 Answers1

2

If I'm reading Exception.cpp correctly, Magick::Exception is too generic. Try isolating the warnings from the errors.

try {
    Magick::Blob buff = Magick::Blob(input, inLen);
    pImage->read(buff);
} catch (Magick::Warning &warning) {
    // Ignore, or log
} catch (Magick::Error &error) {
    cout << error.what() << endl;
    delete(pImage);
    return -1;
}
emcconville
  • 23,800
  • 4
  • 50
  • 66