Better handling for error messages

Fixes walmartlabs/thorax#265