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()
File::File(istream& is, bool validate)
: File()
{
// parser p(is, *this);
// p.parseFile();
load(is);
}
File::File(boost::filesystem::path p, bool validate)
: File()
{
load(p);
try
{
load(p);
}
catch (const exception& ex)
{
throw_with_nested("Error while loading file " + p.string());
}
}
File::File(File&& rhs)
......@@ -2316,7 +2321,14 @@ void File::load(fs::path p)
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)
......
......@@ -500,33 +500,26 @@ SacParser::CIFToken SacParser::getNextToken()
void SacParser::parseFile()
{
try
while (mLookahead != eCIFTokenEOF)
{
while (mLookahead != eCIFTokenEOF)
switch (mLookahead)
{
switch (mLookahead)
{
case eCIFTokenGLOBAL:
parseGlobal();
break;
case eCIFTokenDATA:
produceDatablock(mTokenValue);
case eCIFTokenGLOBAL:
parseGlobal();
break;
case eCIFTokenDATA:
produceDatablock(mTokenValue);
match(eCIFTokenDATA);
parseDataBlock();
break;
default:
error("This file does not seem to be an mmCIF file");
break;
}
match(eCIFTokenDATA);
parseDataBlock();
break;
default:
error("This file does not seem to be an mmCIF file");
break;
}
}
catch (const exception& ex)
{
error(string("Error parsing file: '") + ex.what() + "'");
}
}
void SacParser::parseGlobal()
......
......@@ -421,7 +421,7 @@ Compound::Compound(const fs::path& file, const std::string& id,
}
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)
// if (not file.is_open())
// 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()
......
......@@ -103,8 +103,7 @@ void FileImpl::load(fs::path p)
}
catch (const exception& ex)
{
cerr << "Failed trying to load file " << p << endl;
throw;
throw_with_nested(runtime_error("Error trying to load file " + p.string()));
}
// 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