From 75303d3102717309422d9024b144630b1f623240 Mon Sep 17 00:00:00 2001 From: louis Date: Fri, 6 Dec 2013 16:27:30 +0100 Subject: added more Exception Handling for Image Loading --- HISTORY | 2 +- imagemagickwrapper.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/HISTORY b/HISTORY index 0088052..5fdedb2 100644 --- a/HISTORY +++ b/HISTORY @@ -387,4 +387,4 @@ Version 1.0.0 Version 1.0.1 - fixed a bug in cImageLoader::FirstImageInFolder() - +- added more Exception Handling for Image Loading diff --git a/imagemagickwrapper.c b/imagemagickwrapper.c index 93a7706..8aa6136 100644 --- a/imagemagickwrapper.c +++ b/imagemagickwrapper.c @@ -77,7 +77,14 @@ bool cImageMagickWrapper::LoadImage(std::string FileName, std::string Path, std: buffer.read(imgFile.c_str()); if (config.GetValue("debugImageLoading")) dsyslog("nopacity: %s sucessfully loaded", imgFile.c_str()); - } catch (...) { + } catch( Magick::Warning &warning ) { + dsyslog("nopacity: Magick Warning: %s", warning.what()); + return true; + } catch( Magick::Error &error ) { + dsyslog("nopacity: Magick Error: %s", error.what()); + return false; + } catch(...) { + dsyslog("nopacity: an unknown Magick error occured during image loading"); return false; } return true; @@ -92,7 +99,14 @@ bool cImageMagickWrapper::LoadImage(const char *fullpath) { buffer.read(fullpath); if (config.GetValue("debugImageLoading")) dsyslog("nopacity: %s sucessfully loaded", fullpath); - } catch (...) { + } catch( Magick::Warning &warning ) { + dsyslog("nopacity: Magick Warning: %s", warning.what()); + return true; + } catch( Magick::Error &error ) { + dsyslog("nopacity: Magick Error: %s", error.what()); + return false; + } catch(...) { + dsyslog("nopacity: an unknown Magick error occured during image loading"); return false; } return true; -- cgit v1.2.3