Better error and logging management

This is the companion PR to https://github.com/gem/oq-engine/pull/1370