Re: Return On Error
Posted by Michael Doube on
URL: http://imagej.273.s1.nabble.com/Return-On-Error-tp3690523p3690524.html
Hi David
In a PlugIn the run() method returns void so you can just
return;
If one of the other methods that run() calls finds an error it could
return an error value to run(), which run() then uses to decide whether
or not to return, or do something else.
A common use is to call a showDialog() method in the run() method, which
shows a dialog for user input and returns false if the dialog is
cancelled. When the dialog method returns false then run() returns and
the plugin terminates.
public void run(String arg){
if (!showDialog()){
return;
}
//otherwise keep executing run()
}
If you hit OK, showDialog() returns true and the plugin continues.
Michael
David William Webster wrote:
> Is there any way to return to ImageJ from a plugin when a potential error
> is detected (e.g. if n input parameter has a bad value.) System.exit()
> kicks me all the way out of ImageJ.
>
> David Webster