Skip to content
Snippets Groups Projects
Commit 65498517 authored by valerio's avatar valerio
Browse files

Added IOUnknownFormatException to separate unknown format errors from generic io errors

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1857 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 991126ae
No related branches found
No related tags found
No related merge requests found
...@@ -82,7 +82,7 @@ void FileLoader::LoadObject(const QString& file_name) ...@@ -82,7 +82,7 @@ void FileLoader::LoadObject(const QString& file_name)
if (!obj) { if (!obj) {
try{ try{
obj=FileLoader::TryLoadMap(file_name); obj=FileLoader::TryLoadMap(file_name);
} catch (io::IOException&) { } catch (io::IOUnknownFormatException&) {
return; return;
} }
} }
...@@ -178,7 +178,7 @@ gfx::GfxObjP FileLoader::TryLoadEntity(const QString& file_name, io::EntityIOHan ...@@ -178,7 +178,7 @@ gfx::GfxObjP FileLoader::TryLoadEntity(const QString& file_name, io::EntityIOHan
try{ try{
handler = io::IOManager::Instance().FindEntityImportHandler(file_name.toStdString()); handler = io::IOManager::Instance().FindEntityImportHandler(file_name.toStdString());
} }
catch(io::IOException e){ catch(io::IOUnknownFormatException e){
handler = io::EntityIOHandlerP(); handler = io::EntityIOHandlerP();
} }
} }
...@@ -211,13 +211,13 @@ gfx::GfxObjP FileLoader::TryLoadEntity(const QString& file_name, io::EntityIOHan ...@@ -211,13 +211,13 @@ gfx::GfxObjP FileLoader::TryLoadEntity(const QString& file_name, io::EntityIOHan
} }
#if OST_IMG_ENABLED #if OST_IMG_ENABLED
gfx::GfxObjP FileLoader::TryLoadMap(const QString& filename, io::MapIOHandlerPtr handler) throw(io::IOException) gfx::GfxObjP FileLoader::TryLoadMap(const QString& filename, io::MapIOHandlerPtr handler) throw(io::IOException,io::IOUnknownFormatException)
{ {
if(!handler){ if(!handler){
try{ try{
handler = io::IOManager::Instance().FindMapImportHandlerFile(filename.toStdString(),io::UndefinedImageFormat()); handler = io::IOManager::Instance().FindMapImportHandlerFile(filename.toStdString(),io::UndefinedImageFormat());
} }
catch(io::IOException e){ catch(io::IOUnknownFormatException e){
handler = io::MapIOHandlerPtr(); handler = io::MapIOHandlerPtr();
} }
} }
...@@ -258,7 +258,7 @@ gfx::GfxObjP FileLoader::TryLoadSurface(const QString& filename, io::SurfaceIOHa ...@@ -258,7 +258,7 @@ gfx::GfxObjP FileLoader::TryLoadSurface(const QString& filename, io::SurfaceIOHa
try{ try{
handler = io::IOManager::Instance().FindSurfaceImportHandler(filename.toStdString(),"msms"); handler = io::IOManager::Instance().FindSurfaceImportHandler(filename.toStdString(),"msms");
} }
catch(io::IOException e){ catch(io::IOUnknownFormatException e){
handler = io::SurfaceIOHandlerPtr(); handler = io::SurfaceIOHandlerPtr();
} }
} }
......
...@@ -45,7 +45,7 @@ private: ...@@ -45,7 +45,7 @@ private:
static void HandleError(Message m, gfx::GfxObjP obj); static void HandleError(Message m, gfx::GfxObjP obj);
static gfx::GfxObjP TryLoadEntity(const QString& file_name, io::EntityIOHandlerP handler=io::EntityIOHandlerP()); static gfx::GfxObjP TryLoadEntity(const QString& file_name, io::EntityIOHandlerP handler=io::EntityIOHandlerP());
#if OST_IMG_ENABLED #if OST_IMG_ENABLED
static gfx::GfxObjP TryLoadMap(const QString& filename, io::MapIOHandlerPtr handler=io::MapIOHandlerPtr()) throw(io::IOException); static gfx::GfxObjP TryLoadMap(const QString& filename, io::MapIOHandlerPtr handler=io::MapIOHandlerPtr()) throw(io::IOException,io::IOUnknownFormatException);
#endif #endif
static gfx::GfxObjP TryLoadSurface(const QString& filename, io::SurfaceIOHandlerPtr handler=io::SurfaceIOHandlerPtr()); static gfx::GfxObjP TryLoadSurface(const QString& filename, io::SurfaceIOHandlerPtr handler=io::SurfaceIOHandlerPtr());
static void RunScript(const QString& filename); static void RunScript(const QString& filename);
......
...@@ -44,7 +44,7 @@ DLLEXPORT_OST_IO img::ImageHandle LoadImage(const boost::filesystem::path& loc, ...@@ -44,7 +44,7 @@ DLLEXPORT_OST_IO img::ImageHandle LoadImage(const boost::filesystem::path& loc,
MapIOHandlerPtr map_io = IOManager::Instance().FindMapImportHandlerFile(loc,formatstruct); MapIOHandlerPtr map_io = IOManager::Instance().FindMapImportHandlerFile(loc,formatstruct);
if(!map_io) { if(!map_io) {
throw IOException("could not find io-plugin for " + loc.string()); throw IOUnknownFormatException("could not find io-plugin for " + loc.string());
} }
img::ImageHandle ih = CreateImage(img::Extent(),img::REAL,img::SPATIAL); img::ImageHandle ih = CreateImage(img::Extent(),img::REAL,img::SPATIAL);
...@@ -70,7 +70,7 @@ DLLEXPORT_OST_IO void SaveImage(const img::ImageHandle& image, const boost::file ...@@ -70,7 +70,7 @@ DLLEXPORT_OST_IO void SaveImage(const img::ImageHandle& image, const boost::file
MapIOHandlerPtr map_io = IOManager::Instance().FindMapExportHandlerFile(loc,formatstruct); MapIOHandlerPtr map_io = IOManager::Instance().FindMapExportHandlerFile(loc,formatstruct);
if(!map_io) { if(!map_io) {
throw IOException("could not find io-plugin for " + loc.string()); throw IOUnknownFormatException("could not find io-plugin for " + loc.string());
} }
LOG_DUMP("calling export on map io handle" << std::endl); LOG_DUMP("calling export on map io handle" << std::endl);
map_io->Export(image, loc,formatstruct); map_io->Export(image, loc,formatstruct);
......
...@@ -77,7 +77,7 @@ EntityIOHandlerP IOManager::FindEntityImportHandler(const String& filename, ...@@ -77,7 +77,7 @@ EntityIOHandlerP IOManager::FindEntityImportHandler(const String& filename,
} }
} }
throw IOException("no suitable entity io handler found for "+filename); throw IOUnknownFormatException("no suitable entity io handler found for "+filename);
} }
EntityIOHandlerP IOManager::FindEntityExportHandler(const String& filename, EntityIOHandlerP IOManager::FindEntityExportHandler(const String& filename,
...@@ -89,7 +89,7 @@ EntityIOHandlerP IOManager::FindEntityExportHandler(const String& filename, ...@@ -89,7 +89,7 @@ EntityIOHandlerP IOManager::FindEntityExportHandler(const String& filename,
return (*it)->Create(); return (*it)->Create();
} }
} }
throw IOException("no suitable handler found for "+filename); throw IOUnknownFormatException("no suitable handler found for "+filename);
} }
SequenceIOHandlerPtr IOManager::FindAlignmentImportHandler(const String& filename, SequenceIOHandlerPtr IOManager::FindAlignmentImportHandler(const String& filename,
...@@ -100,7 +100,7 @@ SequenceIOHandlerPtr IOManager::FindAlignmentImportHandler(const String& filenam ...@@ -100,7 +100,7 @@ SequenceIOHandlerPtr IOManager::FindAlignmentImportHandler(const String& filenam
return (*it)->Create(); return (*it)->Create();
} }
} }
throw IOException("no suitable alignment io handler found for "+filename); throw IOUnknownFormatException("no suitable alignment io handler found for "+filename);
} }
SequenceIOHandlerPtr IOManager::FindAlignmentExportHandler(const String& filename, SequenceIOHandlerPtr IOManager::FindAlignmentExportHandler(const String& filename,
...@@ -112,7 +112,7 @@ SequenceIOHandlerPtr IOManager::FindAlignmentExportHandler(const String& filenam ...@@ -112,7 +112,7 @@ SequenceIOHandlerPtr IOManager::FindAlignmentExportHandler(const String& filenam
return (*it)->Create(); return (*it)->Create();
} }
} }
throw IOException("no suitable alignment io handler found for "+filename); throw IOUnknownFormatException("no suitable alignment io handler found for "+filename);
} }
SurfaceIOHandlerPtr IOManager::FindSurfaceImportHandler(const String& filename, SurfaceIOHandlerPtr IOManager::FindSurfaceImportHandler(const String& filename,
...@@ -125,7 +125,7 @@ SurfaceIOHandlerPtr IOManager::FindSurfaceImportHandler(const String& filename, ...@@ -125,7 +125,7 @@ SurfaceIOHandlerPtr IOManager::FindSurfaceImportHandler(const String& filename,
} }
} }
throw IOException("no suitable surface io handler found for "+filename); throw IOUnknownFormatException("no suitable surface io handler found for "+filename);
} }
#if OST_IMG_ENABLED #if OST_IMG_ENABLED
...@@ -138,7 +138,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerFile(const boost::filesystem::pat ...@@ -138,7 +138,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerFile(const boost::filesystem::pat
return (*it)->Create(); return (*it)->Create();
} }
} }
throw IOException("Unsupported type in FindMapImportHandle."); throw IOUnknownFormatException("Unsupported type in FindMapImportHandle.");
}else{ }else{
String match_suf_string=loc.string(); String match_suf_string=loc.string();
std::transform(match_suf_string.begin(),match_suf_string.end(),match_suf_string.begin(),tolower); std::transform(match_suf_string.begin(),match_suf_string.end(),match_suf_string.begin(),tolower);
...@@ -161,7 +161,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerFile(const boost::filesystem::pat ...@@ -161,7 +161,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerFile(const boost::filesystem::pat
return (*it)->Create(); return (*it)->Create();
} }
} }
throw IOException("No file suffix given for " + loc.string()+", and could not detect automatically, please indicate file type."); throw IOUnknownFormatException("No file suffix given for " + loc.string()+", and could not detect automatically, please indicate file type.");
} }
return MapIOHandlerPtr(); // removes warning return MapIOHandlerPtr(); // removes warning
} }
...@@ -175,7 +175,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerStream(std::istream& stream, ...@@ -175,7 +175,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerStream(std::istream& stream,
return (*it)->Create();; return (*it)->Create();;
} }
} }
throw IOException("Unsuspported type in FindMapImportHandle."); throw IOUnknownFormatException("Unsuspported type in FindMapImportHandle.");
}else{ }else{
unsigned char header[256]; unsigned char header[256];
stream.read(reinterpret_cast<char*>(&header),256); stream.read(reinterpret_cast<char*>(&header),256);
...@@ -186,7 +186,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerStream(std::istream& stream, ...@@ -186,7 +186,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerStream(std::istream& stream,
return (*it)->Create();; return (*it)->Create();;
} }
} }
throw IOException("No type given for stream, and could not detect automatically, please indicate file type."); throw IOUnknownFormatException("No type given for stream, and could not detect automatically, please indicate file type.");
} }
return MapIOHandlerPtr(); //removes warning return MapIOHandlerPtr(); //removes warning
} }
...@@ -200,12 +200,12 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerFile(const boost::filesystem::pat ...@@ -200,12 +200,12 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerFile(const boost::filesystem::pat
return (*it)->Create(); return (*it)->Create();
} }
} }
throw IOException("Unsupported type in FindMapExportHandle."); throw IOUnknownFormatException("Unsupported type in FindMapExportHandle.");
}else{ }else{
String filename=loc.string(); String filename=loc.string();
String::size_type pos = filename.rfind("."); String::size_type pos = filename.rfind(".");
if (pos == String::npos){ if (pos == String::npos){
throw IOException("No file suffix given for " + filename+", please indicate file type."); throw IOUnknownFormatException("No file suffix given for " + filename+", please indicate file type.");
} }
String match_suf_string=loc.string(); String match_suf_string=loc.string();
std::transform(match_suf_string.begin(),match_suf_string.end(),match_suf_string.begin(),tolower); std::transform(match_suf_string.begin(),match_suf_string.end(),match_suf_string.begin(),tolower);
...@@ -214,7 +214,7 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerFile(const boost::filesystem::pat ...@@ -214,7 +214,7 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerFile(const boost::filesystem::pat
return(*it)->Create(); return(*it)->Create();
} }
} }
throw IOException("could not find io-plugin for " + filename); throw IOUnknownFormatException("could not find io-plugin for " + filename);
} }
return MapIOHandlerPtr(); // removes the warning return MapIOHandlerPtr(); // removes the warning
} }
...@@ -227,9 +227,9 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerStream(std::istream& stream, cons ...@@ -227,9 +227,9 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerStream(std::istream& stream, cons
return (*it)->Create(); return (*it)->Create();
} }
} }
throw IOException("Unsupported type in FindMapExportHandlerStream"); throw IOUnknownFormatException("Unsupported type in FindMapExportHandlerStream");
} else { } else {
throw IOException("No type given. Please indicate stream type"); throw IOUnknownFormatException("No type given. Please indicate stream type");
} }
return MapIOHandlerPtr(); // removes the warning return MapIOHandlerPtr(); // removes the warning
} }
......
...@@ -36,7 +36,7 @@ void DLLEXPORT_OST_IO SaveEntity(const mol::EntityView& en, ...@@ -36,7 +36,7 @@ void DLLEXPORT_OST_IO SaveEntity(const mol::EntityView& en,
EntityIOHandlerP ent_io=manager.FindEntityExportHandler(filename, format); EntityIOHandlerP ent_io=manager.FindEntityExportHandler(filename, format);
if (!ent_io) { if (!ent_io) {
throw IOException("No IO handler for file='"+filename+"', format='"+ throw IOUnknownFormatException("No IO handler for file='"+filename+"', format='"+
format+"' found."); format+"' found.");
} }
LOG_DUMP("calling export on entity io handle" << std::endl); LOG_DUMP("calling export on entity io handle" << std::endl);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment