Correct generation of error object.