Make recovery of errors common for encode/decode.