Commit 49912d01 by Maarten L. Hekkelman

Better error reporting

parent d4758e09
...@@ -689,9 +689,7 @@ void compound_factory::set_default_dictionary(const fs::path &inDictFile) ...@@ -689,9 +689,7 @@ void compound_factory::set_default_dictionary(const fs::path &inDictFile)
} }
catch (const std::exception &) catch (const std::exception &)
{ {
if (cif::VERBOSE >= 0) std::throw_with_nested(std::runtime_error("Error loading dictionary " + inDictFile.string()));
std::cerr << "Error loading dictionary " << inDictFile << std::endl;
throw;
} }
} }
...@@ -700,19 +698,13 @@ void compound_factory::push_dictionary(const fs::path &inDictFile) ...@@ -700,19 +698,13 @@ void compound_factory::push_dictionary(const fs::path &inDictFile)
if (not fs::exists(inDictFile)) if (not fs::exists(inDictFile))
throw std::runtime_error("file not found: " + inDictFile.string()); throw std::runtime_error("file not found: " + inDictFile.string());
// ifstream file(inDictFile);
// if (not file.is_open())
// throw std::runtime_error("Could not open peptide list " + inDictFile);
try try
{ {
m_impl.reset(new compound_factory_impl(inDictFile, m_impl)); m_impl.reset(new compound_factory_impl(inDictFile, m_impl));
} }
catch (const std::exception &) catch (const std::exception &)
{ {
if (cif::VERBOSE >= 0) std::throw_with_nested(std::runtime_error("Error loading dictionary " + inDictFile.string()));
std::cerr << "Error loading dictionary " << inDictFile << std::endl;
throw;
} }
} }
...@@ -724,14 +716,6 @@ void compound_factory::pop_dictionary() ...@@ -724,14 +716,6 @@ void compound_factory::pop_dictionary()
const compound *compound_factory::create(std::string id) const compound *compound_factory::create(std::string id)
{ {
// static bool warned = false;
// if (m_impl and warned == false)
// {
// std::cerr << "Warning: no compound information library was found, resulting data may be incorrect or incomplete" << std::endl;
// warned = true;
// }
return m_impl ? m_impl->get(id) : nullptr; return m_impl ? m_impl->get(id) : nullptr;
} }
......
...@@ -220,11 +220,11 @@ std::tuple<std::string, std::string> split_tag_name(std::string_view tag) ...@@ -220,11 +220,11 @@ std::tuple<std::string, std::string> split_tag_name(std::string_view tag)
if (tag.empty()) if (tag.empty())
throw std::runtime_error("empty tag"); throw std::runtime_error("empty tag");
if (tag[0] != '_') if (tag[0] != '_')
throw std::runtime_error("tag does not start with underscore"); throw std::runtime_error("tag '" + std::string { tag } + "' does not start with underscore");
auto s = tag.find('.'); auto s = tag.find('.');
if (s == std::string::npos) if (s == std::string::npos)
throw std::runtime_error("tag does not contain dot"); throw std::runtime_error("tag does not contain dot (" + std::string{ tag } + ')');
return std::tuple<std::string, std::string>{ return std::tuple<std::string, std::string>{
tag.substr(1, s - 1), tag.substr(s + 1)}; tag.substr(1, s - 1), tag.substr(s + 1)};
} }
......
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