Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Error handling when using a shell script
richardc
Hi,
We are running reports using a shell script (which contains a java command to call the the ReportRunner class and pass report parameters to it).
The shell script starts execution after receiving input from a job scheduler (java).
Our decision to include the shell script, rather than just keeping everything in java, was so that we could have a separate process from the job scheduler for running reports - this has helped us overcome some jvm oom memory issues.
My question is how can we incorporate error handling so that the when the report throws an exception, it is caught by the ReportRunner class and the error status is then passed back to the shell script? The logic should be like this: if there is an exception in the report for any reason (particularly if the report can't connect to a webservices datasource, or if there is an error due to data from a web service), then
1) stop the report
2) send an error status back to the shell script
3) send an error status from the shell script to the job scheduler
4) exit the shell script
5) stop the job
Is it possible to do this and how can we do it?
Find more posts tagged with
Comments
richardc
I found this link - will try implementing this to allow throwing a BirtException within the reports:<br />
<br />
<a class='bbc_url' href='
http://birtworld.blogspot.com/2009/03/raising-errors-in-event-handlers.html'>Raising
Errors in Event Handlers</a>
richardc
I created a custom scriptlet class as given in the link above and then tested a report template with the following in the initialize event of the report:
ScriptlUtils.addBirtException(reportContext, "Simple Error Message - Hello World2!", BirtException.ERROR);
I then tested this using the BIRT Viewer installed on tomcat and got the exception after running the report - this is good - as expected.
I then tried running the same report via a batch file (which contains a java command to call the the ReportRunner class and pass report parameters to it).
However, the exception did not stop the report from running at all and an error status of 0 was returned to the batch file on completion of the java command.
I would have expected the error level to be propagated back to the batch file.
i.e.
BirtException.OK: should return 0 to the batch file
BirtException.INFO: should return 1 to the batch file
BirtException.WARNING: should return 2 to the batch file
BirtException.ERROR: should return 4 to the batch file
BirtException.CANCEL: should return 8 to the batch file
Is there some way to get the correct error level in the batch file?
I'm using birt-runtime-2_3_2_2
richardc
Just an update - may be useful for others:
I modified the ReportRunner class which is called from the java command in the batch file. I added a method to pick up any exceptions and then get the error level and then use this error level value as the return value in the runAndRenderReport method of the ReportRunner class.
The error level is then passed back to the batch file correctly.