diff --git a/modules/io/src/mol/star_parser.cc b/modules/io/src/mol/star_parser.cc index 9d66fe09e3bce1a869a17db1a27517ef05a70264..45d34907195f6cc825f093061863365c48a0fe6c 100644 --- a/modules/io/src/mol/star_parser.cc +++ b/modules/io/src/mol/star_parser.cc @@ -331,6 +331,7 @@ void StarParser::ParseGlobal() void StarParser::Parse() { StringRef line; + std::stringstream ss; while (this->GetLine(line)) { StringRef tline=line.rtrim(); if (tline.empty()) { @@ -353,8 +354,8 @@ void StarParser::Parse() this->ConsumeLine(); break; default: - std::cout << "ERROR:" << line_num_ << ":" << tline << std::endl; - assert(0 && "unhandled top-level construct in StarParser::Parse()"); + ss << "Missing 'data_' control structure." << std::endl; + throw IOException(ss.str()); break; } } diff --git a/modules/io/tests/test_star_parser.cc b/modules/io/tests/test_star_parser.cc index 0c73327bac3e2234556c332a82447207032f3285..6a19967759c13165e55459216a7018e025a22470 100644 --- a/modules/io/tests/test_star_parser.cc +++ b/modules/io/tests/test_star_parser.cc @@ -21,6 +21,7 @@ */ #include <fstream> #include <ost/mol/mol.hh> +#include <ost/io/io_exception.hh> #include <ost/io/mol/star_parser.hh> #define BOOST_AUTO_TEST_DYN_LINK @@ -179,5 +180,12 @@ BOOST_AUTO_TEST_CASE(star_loop) BOOST_CHECK_EQUAL(star_p.lines[4][1], "14"); BOOST_CHECK_EQUAL(star_p.lines[4][2], "15"); } + +BOOST_AUTO_TEST_CASE(star_missing_data) +{ + std::ifstream s("testfiles/missing_data.cif"); + LoopTestParser star_p(s); + BOOST_CHECK_THROW(star_p.Parse(), IOException); +} BOOST_AUTO_TEST_SUITE_END();