Adapt exception code

make the exception handling code consistent with opm/opm-core#352