Re: Error: Checked exception 'java.io.IOException' is signalled but is not signalled by overridden method - fixed!

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Error: Checked exception 'java.io.IOException' is signalled but is not signalled by overridden method - fixed!

kenner
Thank you, Rene
I see now after much searching that java handles, and the compiler insists on handling, ioexceptions (amoung others I'm sure). What eventually worked for me was to "wrap" a catch in the do block in the actionPerformed method with the call to the method that does the IO.

method actionPerformed(evt=ActionEvent)    
    if Debug_Level > 3 then trace results
         select
                         when evt.getSource() == advanceThruDeck then do
                                         ShowNextCard(Rand1)
                         end
                         when evt.getSource() == SaveExit then do
                                         WriteAndLeave(DaScore)
                                         catch e=IOException --< the WriteAndLeave method signals IOException
                                             say 'I/O Exception.' e.getMessage()
                                         GuiClose()
                         end
                         when evt.getSource() == Submit_Check then do
                                         Submit_Check(A_answer)
                         end
                         when evt.getSource() == PbtRevertToZeros then
                             do
                                         PbtRevertToZeros()
                                         DisplayScore(DaScore)
                   end
                 otherwise say "This should not have happened, darn." -- we don't expect anything else
                 finally DisplayScore(DaScore)
         end

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of René Jansen
Sent: Tuesday, February 05, 2013 6:11 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] Error: Checked exception 'java.io.IOException' is signalled but is not signalled by overridden method

Hi Kenneth,

some exceptions are categorized as 'checked exceptions' - an unfortunate name I think for an unfortunate concept - but it means that they must be accompanied by a 'catch' in your source. You can either:

1) declare them (with 'signals' on the method declaration
2) wrap them in a 'do' ... 'catch' block.

When you choose 1, it is good to catch them in the invoking code.

So a button press can certainly invoke some method that does I/O, but the exception should be caught somewhere, as indicated above.

best regards,

René Jansen.


On 4 feb. 2013, at 20:40, Kenneth Klein (TEMA TPC) <[hidden email]> wrote:

> method actionPerformed(evt=ActionEvent)
> if Debug_Level > 3 then trace results
> select
> when evt.getSource() == advanceThruDeck then do
> ShowNextCard(Rand1)
> end
> when evt.getSource() == SaveExit then do
> WriteAndLeave(DaScore)
> end
> when evt.getSource() == Submit_Check then do
> Submit_Check(A_answer)
> end
> when evt.getSource() == PbtRevertToZeros then
>     do
> PbtRevertToZeros()
> DisplayScore(DaScore)
>
>                    end
>         otherwise say "This should not have happened, darn." -- we don't expect anything else
> finally DisplayScore(DaScore)
> end
>
> I just don't get it. I could have sworn I had this working with the WriteAndLeave method doing some file writing and hence the chance of an IOException. The buttons on my frame have setActionLIstener defined and this button should write the files and exit the program. Does this mean there is no way to have a button that can do file IO?
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
>

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/