Commit f54aa3cb authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

ParserService: Simplify & robustify exceptions handling

If an exception was thrown from the done() callback, the task wasn't
valid anymore, and thus the log output would cause the program to crash.
parent fc04f0a3
......@@ -132,16 +132,17 @@ void ParserService::mainloop()
task = std::move( m_tasks.front() );
m_tasks.pop();
}
parser::Task::Status status;
try
{
auto status = run( *task );
m_parserCb->done( std::move( task ), status );
status = run( *task );
}
catch (const std::exception& ex)
catch ( const std::exception& ex )
{
LOG_ERROR( "Caught an exception during ", task->file->mrl(), " parsing: ", ex.what() );
m_parserCb->done( std::move( task ), parser::Task::Status::Fatal );
status = parser::Task::Status::Fatal;
}
m_parserCb->done( std::move( task ), status );
}
LOG_INFO("Exiting ParserService [", serviceName, "] thread");
}
......
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