applied patch from Jochen (throw an exception if unknown type)

This commit is contained in:
Artem Pavlenko 2007-12-19 16:34:36 +00:00
parent 37f49e29cc
commit 52bed0b89a
2 changed files with 17 additions and 0 deletions

View file

@ -37,6 +37,22 @@
namespace mapnik { 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 <typename T> template <typename T>
MAPNIK_DECL void save_to_file(std::string const& filename, MAPNIK_DECL void save_to_file(std::string const& filename,
std::string const& type, std::string const& type,

View file

@ -55,6 +55,7 @@ namespace mapnik
if (type=="png") save_as_png(file,image); if (type=="png") save_as_png(file,image);
else if (type == "png256") save_as_png256(file,image); else if (type == "png256") save_as_png256(file,image);
else if (type=="jpeg") save_as_jpeg(file,85,image); else if (type=="jpeg") save_as_jpeg(file,85,image);
else throw ImageWriterException("unknown file type: " + type);
} }
} }