exceptions, forward references and signals

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

exceptions, forward references and signals

kenner

 

 

This program was working well until I added a couple of methods to read some files and to move some duplicate code into its own method. Now I get these errors. My misunderstanding is about these exceptions, signals and forward references.  I’m reading:

http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.html

 

but could use some more help.


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

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

Mike Cowlishaw
Looks as though you are overriding ('replacing') a method with one of your own.  The one you are overriding either did not do anything that could cause an IOException, or if it did then it handled them itself.
 
Since you are overriding that method you must (according to Java rules) match that behaviour: either do not do anything that could cause an IOException, or if you do then you must handle (catch) those possible exceptions in the new method.
 
A common cause of 'unexpected' IOExceptions is closing a file -- so a catch/finally that closes a file must have a nested catch to handle any IOException arising from the close.
 
Mike
 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: 14 February 2013 13:25
To: IBM Netrexx
Subject: [Ibm-netrexx] exceptions, forward references and signals

 

 

This program was working well until I added a couple of methods to read some files and to move some duplicate code into its own method. Now I get these errors. My misunderstanding is about these exceptions, signals and forward references.  I’m reading:

http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.html

 

but could use some more help.


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

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

kenner

Thanks, Mike. I’m honored by your reply.

 

This is, as you guessed, the method I am overriding:

 

method keyTyped(e=Keyevent)

                if Debug_Level > 3 then trace results

--  if Debug_Level = 5 then say  " keystyped key A_answer keysaccepted rightAnswers wrongKeys"

                key = Rexx e.getKeyChar() -- make key of type Rexx for further use

                if key.c2d() == KeyEvent.VK_ENTER then Submit_Check(A_answer)

                key = key.upper()

                keystyped = keystyped + 1

                if retrySwitch then return

                key = Rexx e.getKeyChar() -- make key of type Rexx for further use

                if key.c2d() == KeyEvent.VK_BACK_SPACE then return

                say A_answer "<-- this is the answer."

                if keyset.pos(key) == 0 then

                                                e.consume

                else

                                                if key \= A_answer.substr(keysaccepted+1,length1) then

                                                                                e.consume

                                                else do

                                                                                e.setKeyChar(key)

                                                                                keysaccepted = keysaccepted + 1

                                                end

 

But I am not signalling anything in this method. And there is nothing in there to cause an IO Exception. I’m also confused as to how this method gets invoked. Obviously, when a key is typed, but from the main method? From the construtor method? If I take the SIGNALS out of the construtor I get the “due to a forward reference to this method, the following exceptions…” error. Once again I am so confused by all the things that Java does for me under the covers.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mike Cowlishaw
Sent: Thursday, February 14, 2013 8:38 AM
To: 'IBM Netrexx'
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

 

Looks as though you are overriding ('replacing') a method with one of your own.  The one you are overriding either did not do anything that could cause an IOException, or if it did then it handled them itself.

 

Since you are overriding that method you must (according to Java rules) match that behaviour: either do not do anything that could cause an IOException, or if you do then you must handle (catch) those possible exceptions in the new method.

 

A common cause of 'unexpected' IOExceptions is closing a file -- so a catch/finally that closes a file must have a nested catch to handle any IOException arising from the close.

 

Mike

 

 


From: [hidden email] [[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: 14 February 2013 13:25
To: IBM Netrexx
Subject: [Ibm-netrexx] exceptions, forward references and signals

 

 

This program was working well until I added a couple of methods to read some files and to move some duplicate code into its own method. Now I get these errors. My misunderstanding is about these exceptions, signals and forward references.  I’m reading:

http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.html

 

but could use some more help.


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

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

Mike Cowlishaw
Kenneth, no idea of the environment, etc., in which this is so cannot help you much about when this gets invoked, etc.  On the initial problem, at a guess, 'something' in there that you call is signalling an IOException -- you are calling quite a few possible sources of exceptions.     Perhaps try putting do .. catch IOException constructs around all and then a binary search through smaller chunks to identify the source.
 
Hmm, maybe the compiler could be enhanced to help pinpoint sources of uncaught exceptions.
 
Mike

From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: 14 February 2013 14:21
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

Thanks, Mike. I’m honored by your reply.

 

This is, as you guessed, the method I am overriding:

 

method keyTyped(e=Keyevent)

                if Debug_Level > 3 then trace results

--  if Debug_Level = 5 then say  " keystyped key A_answer keysaccepted rightAnswers wrongKeys"

                key = Rexx e.getKeyChar() -- make key of type Rexx for further use

                if key.c2d() == KeyEvent.VK_ENTER then Submit_Check(A_answer)

                key = key.upper()

                keystyped = keystyped + 1

                if retrySwitch then return

                key = Rexx e.getKeyChar() -- make key of type Rexx for further use

                if key.c2d() == KeyEvent.VK_BACK_SPACE then return

                say A_answer "<-- this is the answer."

                if keyset.pos(key) == 0 then

                                                e.consume

                else

                                                if key \= A_answer.substr(keysaccepted+1,length1) then

                                                                                e.consume

                                                else do

                                                                                e.setKeyChar(key)

                                                                                keysaccepted = keysaccepted + 1

                                                end

 

But I am not signalling anything in this method. And there is nothing in there to cause an IO Exception. I’m also confused as to how this method gets invoked. Obviously, when a key is typed, but from the main method? From the construtor method? If I take the SIGNALS out of the construtor I get the “due to a forward reference to this method, the following exceptions…” error. Once again I am so confused by all the things that Java does for me under the covers.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mike Cowlishaw
Sent: Thursday, February 14, 2013 8:38 AM
To: 'IBM Netrexx'
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

 

Looks as though you are overriding ('replacing') a method with one of your own.  The one you are overriding either did not do anything that could cause an IOException, or if it did then it handled them itself.

 

Since you are overriding that method you must (according to Java rules) match that behaviour: either do not do anything that could cause an IOException, or if you do then you must handle (catch) those possible exceptions in the new method.

 

A common cause of 'unexpected' IOExceptions is closing a file -- so a catch/finally that closes a file must have a nested catch to handle any IOException arising from the close.

 

Mike

 

 


From: [hidden email] [[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: 14 February 2013 13:25
To: IBM Netrexx
Subject: [Ibm-netrexx] exceptions, forward references and signals

 

 

This program was working well until I added a couple of methods to read some files and to move some duplicate code into its own method. Now I get these errors. My misunderstanding is about these exceptions, signals and forward references.  I’m reading:

http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.html

 

but could use some more help.


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

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

rickmcguire


On Thu, Feb 14, 2013 at 9:53 AM, Mike Cowlishaw <[hidden email]> wrote:
Kenneth, no idea of the environment, etc., in which this is so cannot help you much about when this gets invoked, etc.  On the initial problem, at a guess, 'something' in there that you call is signalling an IOException -- you are calling quite a few possible sources of exceptions.     Perhaps try putting do .. catch IOException constructs around all and then a binary search through smaller chunks to identify the source.
 
Hmm, maybe the compiler could be enhanced to help pinpoint sources of uncaught exceptions.

I would have thought that the line numbers on the error messages would be giving that information. 

Rick
 
 
Mike

From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: 14 February 2013 14:21

To: IBM Netrexx
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

Thanks, Mike. I’m honored by your reply.

 

This is, as you guessed, the method I am overriding:

 

method keyTyped(e=Keyevent)

                if Debug_Level > 3 then trace results

--  if Debug_Level = 5 then say  " keystyped key A_answer keysaccepted rightAnswers wrongKeys"

                key = Rexx e.getKeyChar() -- make key of type Rexx for further use

                if key.c2d() == KeyEvent.VK_ENTER then Submit_Check(A_answer)

                key = key.upper()

                keystyped = keystyped + 1

                if retrySwitch then return

                key = Rexx e.getKeyChar() -- make key of type Rexx for further use

                if key.c2d() == KeyEvent.VK_BACK_SPACE then return

                say A_answer "<-- this is the answer."

                if keyset.pos(key) == 0 then

                                                e.consume

                else

                                                if key \= A_answer.substr(keysaccepted+1,length1) then

                                                                                e.consume

                                                else do

                                                                                e.setKeyChar(key)

                                                                                keysaccepted = keysaccepted + 1

                                                end

 

But I am not signalling anything in this method. And there is nothing in there to cause an IO Exception. I’m also confused as to how this method gets invoked. Obviously, when a key is typed, but from the main method? From the construtor method? If I take the SIGNALS out of the construtor I get the “due to a forward reference to this method, the following exceptions…” error. Once again I am so confused by all the things that Java does for me under the covers.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mike Cowlishaw
Sent: Thursday, February 14, 2013 8:38 AM
To: 'IBM Netrexx'
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

 

Looks as though you are overriding ('replacing') a method with one of your own.  The one you are overriding either did not do anything that could cause an IOException, or if it did then it handled them itself.

 

Since you are overriding that method you must (according to Java rules) match that behaviour: either do not do anything that could cause an IOException, or if you do then you must handle (catch) those possible exceptions in the new method.

 

A common cause of 'unexpected' IOExceptions is closing a file -- so a catch/finally that closes a file must have a nested catch to handle any IOException arising from the close.

 

Mike

 

 


From: [hidden email] [[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: 14 February 2013 13:25
To: IBM Netrexx
Subject: [Ibm-netrexx] exceptions, forward references and signals

 

 

This program was working well until I added a couple of methods to read some files and to move some duplicate code into its own method. Now I get these errors. My misunderstanding is about these exceptions, signals and forward references.  I’m reading:

http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.html

 

but could use some more help.


_______________________________________________
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/

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

KP Kirchdörfer
In reply to this post by kenner
Kenneth;

I do not know what (program) you are referring to in your mails -
probably some information has been lost in the discussion, probably I
just don't see it.

You wrote:

"I get the "due to a forward reference to this method, the following
exceptions..." error."


Therefor just a wild guess about the exceptions:
You do use KeyEvent
a subclass of java.util.eventObject, which throws an
IllegalArgumentException
if you don't catch or signal it in your method you'll get the error.

kp


Am 14.02.2013 15:20, schrieb Kenneth Klein (TEMA TPC):

> Thanks, Mike. I'm honored by your reply.
>
> This is, as you guessed, the method I am overriding:
>
> method keyTyped(e=Keyevent)
>                 if Debug_Level > 3 then trace results
> --  if Debug_Level = 5 then say  " keystyped key A_answer keysaccepted rightAnswers wrongKeys"
>                 key = Rexx e.getKeyChar() -- make key of type Rexx for further use
>                 if key.c2d() == KeyEvent.VK_ENTER then Submit_Check(A_answer)
>                 key = key.upper()
>                 keystyped = keystyped + 1
>                 if retrySwitch then return
>                 key = Rexx e.getKeyChar() -- make key of type Rexx for further use
>                 if key.c2d() == KeyEvent.VK_BACK_SPACE then return
>                 say A_answer "<-- this is the answer."
>                 if keyset.pos(key) == 0 then
>                                                 e.consume
>                 else
>                                                 if key \= A_answer.substr(keysaccepted+1,length1) then
>                                                                                 e.consume
>                                                 else do
>                                                                                 e.setKeyChar(key)
>                                                                                 keysaccepted = keysaccepted + 1
>                                                 end
>
> But I am not signalling anything in this method. And there is nothing in there to cause an IO Exception. I'm also confused as to how this method gets invoked. Obviously, when a key is typed, but from the main method? From the construtor method? If I take the SIGNALS out of the construtor I get the "due to a forward reference to this method, the following exceptions..." error. Once again I am so confused by all the things that Java does for me under the covers.
>
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Mike Cowlishaw
> Sent: Thursday, February 14, 2013 8:38 AM
> To: 'IBM Netrexx'
> Subject: Re: [Ibm-netrexx] exceptions, forward references and signals
>
> Looks as though you are overriding ('replacing') a method with one of your own.  The one you are overriding either did not do anything that could cause an IOException, or if it did then it handled them itself.
>
> Since you are overriding that method you must (according to Java rules) match that behaviour: either do not do anything that could cause an IOException, or if you do then you must handle (catch) those possible exceptions in the new method.
>
> A common cause of 'unexpected' IOExceptions is closing a file -- so a catch/finally that closes a file must have a nested catch to handle any IOException arising from the close.
>
> Mike
>
>
> ________________________________
> From: [hidden email]<mailto:[hidden email]> [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
> Sent: 14 February 2013 13:25
> To: IBM Netrexx
> Subject: [Ibm-netrexx] exceptions, forward references and signals
>
> [cid:image001.png@01CE0A91.AF846C30]
>
>
>
>
>
> This program was working well until I added a couple of methods to read some files and to move some duplicate code into its own method. Now I get these errors. My misunderstanding is about these exceptions, signals and forward references.  I'm reading:
>
> http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.html
>
>
>
> but could use some more help.
>
>
>
> _______________________________________________
> 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/

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

kenner

Yes I am in fact using keyevent and keytyped. The exception the compiler says I am not handling is ioEception. When the error messages started showing up,  I added singnals to every method the error messages listed as needing it. I had that working but now I am getting the error about the overridden method not handing that exception.

 

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of KP Kirchdörfer
Sent: Thursday, February 14, 2013 10:14 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

 

Kenneth;

 

I do not know what (program) you are referring to in your mails - probably some information has been lost in the discussion, probably I just don't see it.

 

You wrote:

 

"I get the "due to a forward reference to this method, the following exceptions..." error."

 

 

Therefor just a wild guess about the exceptions:

You do use KeyEvent

a subclass of java.util.eventObject, which throws an IllegalArgumentException if you don't catch or signal it in your method you'll get the error.

 

kp

 

 

Am 14.02.2013 15:20, schrieb Kenneth Klein (TEMA TPC):

> Thanks, Mike. I'm honored by your reply.

>

> This is, as you guessed, the method I am overriding:

>

> method keyTyped(e=Keyevent)

>                 if Debug_Level > 3 then trace results

> --  if Debug_Level = 5 then say  " keystyped key A_answer keysaccepted rightAnswers wrongKeys"

>                 key = Rexx e.getKeyChar() -- make key of type Rexx for further use

>                 if key.c2d() == KeyEvent.VK_ENTER then Submit_Check(A_answer)

>                 key = key.upper()

>                 keystyped = keystyped + 1

>                 if retrySwitch then return

>                 key = Rexx e.getKeyChar() -- make key of type Rexx for further use

>                 if key.c2d() == KeyEvent.VK_BACK_SPACE then return

>                 say A_answer "<-- this is the answer."

>                 if keyset.pos(key) == 0 then

>                                                 e.consume

>                 else

>                                                 if key \= A_answer.substr(keysaccepted+1,length1) then

>                                                                                 e.consume

>                                                 else do

>                                                                                 e.setKeyChar(key)

>                                                                                 keysaccepted = keysaccepted + 1

>                                                 end

>

> But I am not signalling anything in this method. And there is nothing in there to cause an IO Exception. I'm also confused as to how this method gets invoked. Obviously, when a key is typed, but from the main method? From the construtor method? If I take the SIGNALS out of the construtor I get the "due to a forward reference to this method, the following exceptions..." error. Once again I am so confused by all the things that Java does for me under the covers.

>

> From: [hidden email]

> [[hidden email]] On Behalf Of Mike

> Cowlishaw

> Sent: Thursday, February 14, 2013 8:38 AM

> To: 'IBM Netrexx'

> Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

>

> Looks as though you are overriding ('replacing') a method with one of your own.  The one you are overriding either did not do anything that could cause an IOException, or if it did then it handled them itself.

>

> Since you are overriding that method you must (according to Java rules) match that behaviour: either do not do anything that could cause an IOException, or if you do then you must handle (catch) those possible exceptions in the new method.

>

> A common cause of 'unexpected' IOExceptions is closing a file -- so a catch/finally that closes a file must have a nested catch to handle any IOException arising from the close.

>

> Mike

>

>

> ________________________________

> From:

> [hidden email]

> .ibm.com> [[hidden email]] On Behalf Of

> Kenneth Klein (TEMA TPC)

> Sent: 14 February 2013 13:25

> To: IBM Netrexx

> Subject: [Ibm-netrexx] exceptions, forward references and signals

>

> [<a href="cid:image001.png@01CE0A91.AF846C30">cid:image001.png@01CE0A91.AF846C30]

>

>

>

>

>

> This program was working well until I added a couple of methods to read some files and to move some duplicate code into its own method. Now I get these errors. My misunderstanding is about these exceptions, signals and forward references.  I'm reading:

>

> http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.ht

> ml

>

>

>

> but could use some more help.

>

>

>

> _______________________________________________

> 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/

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

Mike Cowlishaw
 
 

Yes I am in fact using keyevent and keytyped. The exception the compiler says I am not handling is ioEception. When the error messages started showing up,  I added singnals to every method the error messages listed as needing it. I had that working but now I am getting the error about the overridden method not handing that exception. 

 

Adding SIGNALS to the method is not the right thing to do unless the method you are overriding already has that same SIGNALS.  Methods that call it will not be expecting IOExceptions.

 

If you generate IOExceptions (from things that you call) then you must handle (catch) them in your method: you cannot pass them to a caller that does not expect them. 


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

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

measel
In reply to this post by kenner

Not to be smartie but Keyboard is IO. 

 

The couch potato uses a big DO in the run method with all the catches arranged at the end. 

 

/*  */

/*  classdef and other methods */

/* */

              

method run() 

                             

do

              

--main routine

--several lines of code doing just about everything except declaring another method

--

catch e3=IOException

               say 'Exception caught:' e3 '\n  ' e3.getMessage()

 

        catch e4 = NullPointerException

               say 'Exception caught:' e4 '\n  ' e4.getMessage()

 

        catch e5 = InterruptedException

               say 'Exception caught:' e5 '\n  ' e5.getMessage()

                             

catch t1 = SnmpTimeoutException

               say dt '[INFO] [EPAClass SNMPGet] Timeout polling ' IP '  ' t1.getMessage()

               do

               parse pbdfile pbdName '.pbd'

               say dt '[INFO] [EPAClass SNMPGet] Restarting collector for ' IP ' from ' pbdfile

                retryCount = retryCount + 1

               jg = justGet(IP, selectedPort, selectedCmty, pbdName, prtWrt,retryCount)

                              Thread(jg,pbdName).start()

                                             end

                              return

                                            

catch v1 = SnmpValueException

                                             exmsg = v1.getMessage()

                                             -- say 'vmsg'  v1

                                             if exmsg = 'empty oid' then

                                                            do

                                                            say '========>' exmsg

                                                            say '   ' metricName ' type= ' metricType

                                                            end

                                             else

                                                            do

                                             parse exmsg . ',idx=' pbdidx ']'

                                             pbdidx = pbdidx.strip()

                                             pbdindex = pbdidx.format()

                                             pbdline = oids[pbdindex]

                                             parse pbdline . metricName

                                             say dt '[ERROR] [EPAClass SNMPGet] ' IP '-- Value exception -- ' pbdfile ' entry ' pbdidx ' metric ' metricName  

                                              end

               return                  

end --end of run thread  and end of big do

return

From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: Thursday, February 14, 2013 2:28 PM
To: [hidden email]; IBM Netrexx
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

 

Yes I am in fact using keyevent and keytyped. The exception the compiler says I am not handling is ioEception. When the error messages started showing up,  I added singnals to every method the error messages listed as needing it. I had that working but now I am getting the error about the overridden method not handing that exception.

 

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of KP Kirchdörfer
Sent: Thursday, February 14, 2013 10:14 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

 

Kenneth;

 

I do not know what (program) you are referring to in your mails - probably some information has been lost in the discussion, probably I just don't see it.

 

You wrote:

 

"I get the "due to a forward reference to this method, the following exceptions..." error."

 

 

Therefor just a wild guess about the exceptions:

You do use KeyEvent

a subclass of java.util.eventObject, which throws an IllegalArgumentException if you don't catch or signal it in your method you'll get the error.

 

kp

 

 

Am 14.02.2013 15:20, schrieb Kenneth Klein (TEMA TPC):

> Thanks, Mike. I'm honored by your reply.

>

> This is, as you guessed, the method I am overriding:

>

> method keyTyped(e=Keyevent)

>                 if Debug_Level > 3 then trace results

> --  if Debug_Level = 5 then say  " keystyped key A_answer keysaccepted rightAnswers wrongKeys"

>                 key = Rexx e.getKeyChar() -- make key of type Rexx for further use

>                 if key.c2d() == KeyEvent.VK_ENTER then Submit_Check(A_answer)

>                 key = key.upper()

>                 keystyped = keystyped + 1

>                 if retrySwitch then return

>                 key = Rexx e.getKeyChar() -- make key of type Rexx for further use

>                 if key.c2d() == KeyEvent.VK_BACK_SPACE then return

>                 say A_answer "<-- this is the answer."

>                 if keyset.pos(key) == 0 then

>                                                 e.consume

>                 else

>                                                 if key \= A_answer.substr(keysaccepted+1,length1) then

>                                                                                 e.consume

>                                                 else do

>                                                                                 e.setKeyChar(key)

>                                                                                 keysaccepted = keysaccepted + 1

>                                                 end

>

> But I am not signalling anything in this method. And there is nothing in there to cause an IO Exception. I'm also confused as to how this method gets invoked. Obviously, when a key is typed, but from the main method? From the construtor method? If I take the SIGNALS out of the construtor I get the "due to a forward reference to this method, the following exceptions..." error. Once again I am so confused by all the things that Java does for me under the covers.

>

> From: [hidden email]

> [[hidden email]] On Behalf Of Mike

> Cowlishaw

> Sent: Thursday, February 14, 2013 8:38 AM

> To: 'IBM Netrexx'

> Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

>

> Looks as though you are overriding ('replacing') a method with one of your own.  The one you are overriding either did not do anything that could cause an IOException, or if it did then it handled them itself.

>

> Since you are overriding that method you must (according to Java rules) match that behaviour: either do not do anything that could cause an IOException, or if you do then you must handle (catch) those possible exceptions in the new method.

>

> A common cause of 'unexpected' IOExceptions is closing a file -- so a catch/finally that closes a file must have a nested catch to handle any IOException arising from the close.

>

> Mike

>

>

> ________________________________

> From:

> [hidden email]

> .ibm.com> [[hidden email]] On Behalf Of

> Kenneth Klein (TEMA TPC)

> Sent: 14 February 2013 13:25

> To: IBM Netrexx

> Subject: [Ibm-netrexx] exceptions, forward references and signals

>

> [<a href="cid:image001.png@01CE0A91.AF846C30">cid:image001.png@01CE0A91.AF846C30]

>

>

>

>

>

> This program was working well until I added a couple of methods to read some files and to move some duplicate code into its own method. Now I get these errors. My misunderstanding is about these exceptions, signals and forward references.  I'm reading:

>

> http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.ht

> ml

>

>

>

> but could use some more help.

>

>

>

> _______________________________________________

> 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/

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

kenner

OK, I think the hole in my understanding was that a method that calls a method that could signal an exception has to handle that exception as well. Doh.

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Measel, Mike
Sent: Thursday, February 14, 2013 4:33 PM
To: IBM Netrexx; [hidden email]
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

 

Not to be smartie but Keyboard is IO. 

 

The couch potato uses a big DO in the run method with all the catches arranged at the end. 

 

/*  */

/*  classdef and other methods */

/* */

              

method run() 

                             

do

              

--main routine

--several lines of code doing just about everything except declaring another method

--

catch e3=IOException

               say 'Exception caught:' e3 '\n  ' e3.getMessage()

 

        catch e4 = NullPointerException

               say 'Exception caught:' e4 '\n  ' e4.getMessage()

 

        catch e5 = InterruptedException

               say 'Exception caught:' e5 '\n  ' e5.getMessage()

                             

catch t1 = SnmpTimeoutException

               say dt '[INFO] [EPAClass SNMPGet] Timeout polling ' IP '  ' t1.getMessage()

               do

               parse pbdfile pbdName '.pbd'

               say dt '[INFO] [EPAClass SNMPGet] Restarting collector for ' IP ' from ' pbdfile

                retryCount = retryCount + 1

               jg = justGet(IP, selectedPort, selectedCmty, pbdName, prtWrt,retryCount)

                              Thread(jg,pbdName).start()

                                             end

                              return

                                            

catch v1 = SnmpValueException

                                             exmsg = v1.getMessage()

                                             -- say 'vmsg'  v1

                                             if exmsg = 'empty oid' then

                                                            do

                                                            say '========>' exmsg

                                                            say '   ' metricName ' type= ' metricType

                                                            end

                                             else

                                                            do

                                             parse exmsg . ',idx=' pbdidx ']'

                                             pbdidx = pbdidx.strip()

                                             pbdindex = pbdidx.format()

                                             pbdline = oids[pbdindex]

                                             parse pbdline . metricName

                                             say dt '[ERROR] [EPAClass SNMPGet] ' IP '-- Value exception -- ' pbdfile ' entry ' pbdidx ' metric ' metricName  

                                              end

               return                  

end --end of run thread  and end of big do

return

From: [hidden email] [[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: Thursday, February 14, 2013 2:28 PM
To: [hidden email]; IBM Netrexx
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

 

Yes I am in fact using keyevent and keytyped. The exception the compiler says I am not handling is ioEception. When the error messages started showing up,  I added singnals to every method the error messages listed as needing it. I had that working but now I am getting the error about the overridden method not handing that exception.

 

 

-----Original Message-----
From: [hidden email] [[hidden email]] On Behalf Of KP Kirchdörfer
Sent: Thursday, February 14, 2013 10:14 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

 

Kenneth;

 

I do not know what (program) you are referring to in your mails - probably some information has been lost in the discussion, probably I just don't see it.

 

You wrote:

 

"I get the "due to a forward reference to this method, the following exceptions..." error."

 

 

Therefor just a wild guess about the exceptions:

You do use KeyEvent

a subclass of java.util.eventObject, which throws an IllegalArgumentException if you don't catch or signal it in your method you'll get the error.

 

kp

 

 

Am 14.02.2013 15:20, schrieb Kenneth Klein (TEMA TPC):

> Thanks, Mike. I'm honored by your reply.

>

> This is, as you guessed, the method I am overriding:

>

> method keyTyped(e=Keyevent)

>                 if Debug_Level > 3 then trace results

> --  if Debug_Level = 5 then say  " keystyped key A_answer keysaccepted rightAnswers wrongKeys"

>                 key = Rexx e.getKeyChar() -- make key of type Rexx for further use

>                 if key.c2d() == KeyEvent.VK_ENTER then Submit_Check(A_answer)

>                 key = key.upper()

>                 keystyped = keystyped + 1

>                 if retrySwitch then return

>                 key = Rexx e.getKeyChar() -- make key of type Rexx for further use

>                 if key.c2d() == KeyEvent.VK_BACK_SPACE then return

>                 say A_answer "<-- this is the answer."

>                 if keyset.pos(key) == 0 then

>                                                 e.consume

>                 else

>                                                 if key \= A_answer.substr(keysaccepted+1,length1) then

>                                                                                 e.consume

>                                                 else do

>                                                                                 e.setKeyChar(key)

>                                                                                 keysaccepted = keysaccepted + 1

>                                                 end

>

> But I am not signalling anything in this method. And there is nothing in there to cause an IO Exception. I'm also confused as to how this method gets invoked. Obviously, when a key is typed, but from the main method? From the construtor method? If I take the SIGNALS out of the construtor I get the "due to a forward reference to this method, the following exceptions..." error. Once again I am so confused by all the things that Java does for me under the covers.

>

> From: [hidden email]

> [[hidden email]] On Behalf Of Mike

> Cowlishaw

> Sent: Thursday, February 14, 2013 8:38 AM

> To: 'IBM Netrexx'

> Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

>

> Looks as though you are overriding ('replacing') a method with one of your own.  The one you are overriding either did not do anything that could cause an IOException, or if it did then it handled them itself.

>

> Since you are overriding that method you must (according to Java rules) match that behaviour: either do not do anything that could cause an IOException, or if you do then you must handle (catch) those possible exceptions in the new method.

>

> A common cause of 'unexpected' IOExceptions is closing a file -- so a catch/finally that closes a file must have a nested catch to handle any IOException arising from the close.

>

> Mike

>

>

> ________________________________

> From:

> [hidden email]

> .ibm.com> [[hidden email]] On Behalf Of

> Kenneth Klein (TEMA TPC)

> Sent: 14 February 2013 13:25

> To: IBM Netrexx

> Subject: [Ibm-netrexx] exceptions, forward references and signals

>

> [<a href="cid:image001.png@01CE0A91.AF846C30">cid:image001.png@01CE0A91.AF846C30]

>

>

>

>

>

> This program was working well until I added a couple of methods to read some files and to move some duplicate code into its own method. Now I get these errors. My misunderstanding is about these exceptions, signals and forward references.  I'm reading:

>

> http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.ht

> ml

>

>

>

> but could use some more help.

>

>

>

> _______________________________________________

> 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/

Reply | Threaded
Open this post in threaded view
|

Re: exceptions, forward references and signals

Mike Cowlishaw
Just to clarify .. if the method you call handles the exception them it will never get to you so you don't have to handle it.   However if it does not handle it then it must say 'signals' in its method description -- which you should see in its documentation -- and then you have to handle it (or pass it on to your caller by specifying 'signals' in your method statement.
 
However you cannot take the latter course when overriding a method that does not signal the exception because there is nothing 'higher up' that is expecting to handle it.
 
Mike
 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: 15 February 2013 15:33
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] exceptions, forward references and signals

OK, I think the hole in my understanding was that a method that calls a method that could signal an exception has to handle that exception as well. Doh.

 

 

 

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