Commit b5f159c3 by maarten

error handling

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@366 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 958d1fb3
...@@ -2245,15 +2245,20 @@ File::File() ...@@ -2245,15 +2245,20 @@ File::File()
File::File(istream& is, bool validate) File::File(istream& is, bool validate)
: File() : File()
{ {
// parser p(is, *this);
// p.parseFile();
load(is); load(is);
} }
File::File(boost::filesystem::path p, bool validate) File::File(boost::filesystem::path p, bool validate)
: File() : File()
{ {
load(p); try
{
load(p);
}
catch (const exception& ex)
{
throw_with_nested("Error while loading file " + p.string());
}
} }
File::File(File&& rhs) File::File(File&& rhs)
...@@ -2316,7 +2321,14 @@ void File::load(fs::path p) ...@@ -2316,7 +2321,14 @@ void File::load(fs::path p)
in.push(inFile); in.push(inFile);
load(in); try
{
load(in);
}
catch (const exception& ex)
{
throw_with_nested(runtime_error("Error loading file " + p.string()));
}
} }
void File::save(fs::path p) void File::save(fs::path p)
......
...@@ -500,33 +500,26 @@ SacParser::CIFToken SacParser::getNextToken() ...@@ -500,33 +500,26 @@ SacParser::CIFToken SacParser::getNextToken()
void SacParser::parseFile() void SacParser::parseFile()
{ {
try while (mLookahead != eCIFTokenEOF)
{ {
while (mLookahead != eCIFTokenEOF) switch (mLookahead)
{ {
switch (mLookahead) case eCIFTokenGLOBAL:
{ parseGlobal();
case eCIFTokenGLOBAL: break;
parseGlobal();
break; case eCIFTokenDATA:
produceDatablock(mTokenValue);
case eCIFTokenDATA:
produceDatablock(mTokenValue);
match(eCIFTokenDATA); match(eCIFTokenDATA);
parseDataBlock(); parseDataBlock();
break; break;
default: default:
error("This file does not seem to be an mmCIF file"); error("This file does not seem to be an mmCIF file");
break; break;
}
} }
} }
catch (const exception& ex)
{
error(string("Error parsing file: '") + ex.what() + "'");
}
} }
void SacParser::parseGlobal() void SacParser::parseGlobal()
......
...@@ -421,7 +421,7 @@ Compound::Compound(const fs::path& file, const std::string& id, ...@@ -421,7 +421,7 @@ Compound::Compound(const fs::path& file, const std::string& id,
} }
catch (...) catch (...)
{ {
throw_with_nested(runtime_error("Error loading ccp4 file for " + id)); throw_with_nested(runtime_error("Error loading ccp4 file for " + id + " from file " + file.string()));
} }
} }
...@@ -1333,7 +1333,14 @@ void CompoundFactory::pushDictionary(const string& inDictFile) ...@@ -1333,7 +1333,14 @@ void CompoundFactory::pushDictionary(const string& inDictFile)
// if (not file.is_open()) // if (not file.is_open())
// throw runtime_error("Could not open peptide list " + inDictFile); // throw runtime_error("Could not open peptide list " + inDictFile);
mImpl = new CompoundFactoryImpl(inDictFile, mImpl); try
{
mImpl = new CompoundFactoryImpl(inDictFile, mImpl);
}
catch (const exception& ex)
{
throw_with_nested(runtime_error("When trying to load dictionary file " + inDictFile));
}
} }
void CompoundFactory::popDictionary() void CompoundFactory::popDictionary()
......
...@@ -103,8 +103,7 @@ void FileImpl::load(fs::path p) ...@@ -103,8 +103,7 @@ void FileImpl::load(fs::path p)
} }
catch (const exception& ex) catch (const exception& ex)
{ {
cerr << "Failed trying to load file " << p << endl; throw_with_nested(runtime_error("Error trying to load file " + p.string()));
throw;
} }
// Yes, we've parsed the data. Now locate the datablock. // Yes, we've parsed the data. Now locate the datablock.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment