PIR-868: Added more context to prepare method so that PIR can save the generated report as PRPT
PRD-3985: Better error handling, so that the log shows the root cause of errors.