Skip to content
Snippets Groups Projects
Commit 377c5a48 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

simplify exceptions handling

parent 530506aa
No related branches found
No related tags found
No related merge requests found
......@@ -47,14 +47,6 @@ int main(int argc, char** argv) {
std::deque<sax::Token> tokens1 = sax::FromXMLParserHelper::parseInput(input1);
std::deque<sax::Token> tokens2 = sax::FromXMLParserHelper::parseInput(input2);
 
if (tokens1.empty() && tokens2.empty()) throw exception::CommonException("Invalid arguments tokens streams 1 and 2 are empty.");
if (tokens1.empty()) throw exception::CommonException("Invalid arguments tokens stream 1 is empty.");
if (tokens2.empty()) throw exception::CommonException("Invalid arguments tokens stream 2 is empty.");
if(alib::XmlDataFactory::first<exception::CommonException>(tokens1)) std::cerr << alib::XmlDataFactory::fromTokens<exception::CommonException>(std::move(tokens1)).getCause() << std::endl; //TODO is this realy needed?
if(alib::XmlDataFactory::first<exception::CommonException>(tokens2)) std::cerr << alib::XmlDataFactory::fromTokens<exception::CommonException>(std::move(tokens2)).getCause() << std::endl;
if(alib::XmlDataFactory::first<exception::CommonException>(tokens1) || alib::XmlDataFactory::first<exception::CommonException>(tokens2)) return 0;
int res;
 
if(alib::XmlDataFactory::first<automaton::Automaton>(tokens1) && alib::XmlDataFactory::first<automaton::Automaton>(tokens2)) {
......
......@@ -104,6 +104,8 @@ public:
*/
template < class T >
static bool first ( const std::deque < sax::Token > & tokens ) {
if( tokens.empty ( ) ) throw exception::CommonException ( "Empty tokens list" );
return alib::xmlApi < exception::CommonException >::first ( tokens.begin ( ) ) || alib::xmlApi < T >::first ( tokens.begin ( ) );
}
 
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment