Bugfix Smart error handler

Bugfix for extreme cases of null reports and also
a few cases where jobs could get stuck in jobfailed.
Merge pull request #4407 from dballesteros7/fixErrorHandlerSmart

Bugfix Smart error handler