closing the Exception window

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

closing the Exception window

John Alexander-7
Hi everyone,

I have a macro that uses a plug in that on occasion throws an Exception.
 It isn't a problem - but I am trying to build in handling for this.
Right now I have this:

if (isOpen("Exception")) {
     print("SLD: "+SLD+":   "+SLDdir+SLDname+" threw an exception");
     selectWindow("Exception");
     close();
     }

I get my Log window with my printed statement, but the close() fails by
saying there is no window "Exception".

any ideas?



--
John K. Alexander, Ph.D.
Post-Doctoral Fellow
William Green Laboratory
University of Chicago
Dept. Neurobiology, Pharmacology, and Physiology
947 East 58th Street
Abott Hall 402
Chicago, IL 60637
(off) 773-702-9386
(fax) 773-702-3774
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: closing the Exception window

Ray Schneider
You probably need to place the plug-in call  in a try block so you can
catch the exception that is thrown.  Just a guess though since I'm
pretty much a newbie when it comes to ImageJ.
I don't know if you can catch exceptions is other ways.
Regards,
Ray
--
Ray Schneider,PE, Ph.D
Assistant Professor
Math and Computer Science
http://www.bridgewater.edu/~rschneid/

John Alexander wrote:

>Hi everyone,
>
>I have a macro that uses a plug in that on occasion throws an Exception.
> It isn't a problem - but I am trying to build in handling for this.
>Right now I have this:
>
>if (isOpen("Exception")) {
>     print("SLD: "+SLD+":   "+SLDdir+SLDname+" threw an exception");
>     selectWindow("Exception");
>     close();
>     }
>
>I get my Log window with my printed statement, but the close() fails by
>saying there is no window "Exception".
>
>any ideas?
>
>
>
>  
>
Reply | Threaded
Open this post in threaded view
|

Re: closing the Exception window

Wayne Rasband
In reply to this post by John Alexander-7
> Hi everyone,
>
> I have a macro that uses a plug in that on occasion throws an
> Exception.
>  It isn't a problem - but I am trying to build in handling for this.
> Right now I have this:
>
> if (isOpen("Exception")) {
>      print("SLD: "+SLD+":   "+SLDdir+SLDname+" threw an exception");
>      selectWindow("Exception");
>      close();
>      }
>
> I get my Log window with my printed statement, but the close() fails by
> saying there is no window "Exception".

Use run("Close") instead of close(). The close() function only works
with image windows.

-wayne