exceptions in ruby

M

Martin Durai

Could any one tell me the related exception in ruby. I am in process of
porting java methods. As java uses lots of inbuilt exception its very
difficult for me to port. could any one help me to tell the related
things in ruby

ArrayIndexOutOfBoundsException
RuntimeException
XmlPullParserException
IllegalArgumentException
UnsupportedEncodingException
IndexOutOfBoundsException
IOException
EOFException
NullPointerException
ClassNotFoundException
ConcurrentModificationException (Iterators throw them)

Thanks in advance
 
R

Robert Dober

Could any one tell me the related exception in ruby. I am in process of
porting java methods. As java uses lots of inbuilt exception its very
difficult for me to port. could any one help me to tell the related
things in ruby

Unfortunately a matching will not be possible, I am not sure if the
following list does you any good
but in some situations similar exceptions might be raised in Ruby, it
of course depends a lot
of how you translate, I still maintain my statement from the other
tread, Java cannot be translated to Ruby as
such, you need to rethink the code, maybe the following examples show
better what I meant:
ArrayIndexOutOfBoundsException
IndexError, but this cannot be ported easily, it is
only raised in specific situations
e.g. x=[]; x[12] -> nil
RuntimeException same name
XmlPullParserException
depends on your XML Toolkit, unlikely to find a correspondance
IllegalArgumentException ParameterError
UnsupportedEncodingException
RobertHasNoClueException_SORRY ;)
IndexOutOfBoundsException IndexError
EOFError
NullPointerException
NoMethodError in some cases, there is no such thing
in reality, I assume that the receiver is
nil but you believe it is something else
ClassNotFoundException
depends on the context, NameError in some cases
ConcurrentModificationException (Iterators throw them) I believe there is none

Thanks in advance
Robert
 
R

Robert Dober

Are you sure you didn't mean to write "ArgumentError"?
I meant to write ParameterError, of course, boldly ;)

502/6 > irb
irb(main):001:0> ArgumentError
=> ArgumentError
irb(main):002:0> ParameterError
NameError: uninitialized constant ParameterError
from (irb):2
irb(main):003:0>

and wrongly :(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,270
Messages
2,571,353
Members
48,038
Latest member
HunterDela

Latest Threads

Top