Change report output and move it inside the try/catch block, because it
can throw an exception.