Fix behaviour of codecs in the presence of errors: they now behave according to the .mli doc.