I have written an ant task (bnd) that needs to indicate failure. The only way to indicate failure that I found is to throw a BuildException
/ExitStatusException
. However, I do not want a stack trace because it just takes up unnecessary screen space. Any idea how to achieve this?
Whenever a certain function call throws an error, you'll have a collection of function calls that lead up to the call that caused the particular problem. This is due to the LIFO behavior of the collection that keeps track of underlying, previous function calls. This also implies that a stack trace is printed top-down.
Using printStackTrace() method − It print the name of the exception, description and complete stack trace including the line where exception occurred. Using toString() method − It prints the name and description of the exception. Using getMessage() method − Mostly used. It prints the description of the exception.
Logging the stack traces of runtime exceptions assists developers in diagnosing runtime failures. However, unnecessary logging of exception stack traces can have many negative impacts such as polluting log files.
Check out the tutorial at http://ant.apache.org/manual/tutorial-writing-tasks.html#complex
There they show an example that just fails gracefully, throwing a BuildException in the custom task but not showing the stack trace in the console window.
The code to pay attention to is in the execute()
method of the 'HelloWorld
' Class, and where the helloworld
task is called from the use.fail
target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With