I'd prefer referencing it as record.getId() in the exception handlers rather than re-setting messageId here.