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); } }