Add error handling to generated json codec