+ throw image_reader_exception if we can't read tiff file

+ catch image_reader_exceptions in raster.input
+ re-throw in bind()
This commit is contained in:
Artem Pavlenko 2011-04-11 21:17:10 +00:00
parent c906dcea02
commit 7191d56a16
3 changed files with 15 additions and 5 deletions

View file

@ -97,7 +97,7 @@ void raster_datasource::bind() const
if (! boost::filesystem::exists(filename_))
throw datasource_exception("Raster Plugin: " + filename_ + " does not exist");
try
{
std::auto_ptr<image_reader> reader(mapnik::get_image_reader(filename_, format_));
@ -111,11 +111,17 @@ void raster_datasource::bind() const
#endif
}
}
catch (mapnik::image_reader_exception const& ex)
{
std::cerr << "Raster Plugin: image reader exception caught:" << ex.what() << std::endl;
throw;
}
catch (...)
{
std::cerr << "Raster Plugin: exception caught" << std::endl;
throw;
}
is_bound_ = true;
}

View file

@ -102,6 +102,10 @@ feature_ptr raster_featureset<LookupPolicy>::next()
}
}
}
catch (mapnik::image_reader_exception const& ex)
{
std::cerr << "Raster Plugin: image reader exception caught:" << ex.what() << std::endl;
}
catch (...)
{
std::cerr << "Raster Plugin: exception caught" << std::endl;

View file

@ -97,10 +97,10 @@ void tiff_reader::init()
// TODO: error handling
TIFFSetWarningHandler(0);
TIFF* tif = load_if_exists(file_name_);
if (!tif) return;
if (!tif) throw image_reader_exception ("Can't load tiff file");
char msg[1024];
if (TIFFRGBAImageOK(tif,msg))
{
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width_);