applied patch from Jochen (throw an exception if unknown type)
This commit is contained in:
parent
37f49e29cc
commit
52bed0b89a
2 changed files with 17 additions and 0 deletions
|
@ -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 <typename T>
|
||||
MAPNIK_DECL void save_to_file(std::string const& filename,
|
||||
std::string const& type,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue