From 52bed0b89a1dca99c94af91f606b3da4b7de5f43 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 19 Dec 2007 16:34:36 +0000 Subject: [PATCH] applied patch from Jochen (throw an exception if unknown type) --- include/mapnik/image_util.hpp | 16 ++++++++++++++++ src/image_util.cpp | 1 + 2 files changed, 17 insertions(+) diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index 1d0f9cea2..f31a18ccf 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -37,6 +37,22 @@ namespace mapnik { + class ImageWriterException : public std::exception + { + private: + std::string message_; + public: + ImageWriterException(const std::string& message) + : message_(message) {} + + ~ImageWriterException() throw() {} + + virtual const char* what() const throw() + { + return message_.c_str(); + } + }; + template MAPNIK_DECL void save_to_file(std::string const& filename, std::string const& type, diff --git a/src/image_util.cpp b/src/image_util.cpp index d694dd8b9..e8520cbe9 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -55,6 +55,7 @@ namespace mapnik if (type=="png") save_as_png(file,image); else if (type == "png256") save_as_png256(file,image); else if (type=="jpeg") save_as_jpeg(file,85,image); + else throw ImageWriterException("unknown file type: " + type); } }