# Exceptions in ruby

**URL:** <https://www.ruby-forum.com/t/exceptions-in-ruby/120982>\
**Category:** Ruby\
**Created:** [November 22, 2007, 11:30am UTC](https://www.ruby-forum.com/t/exceptions-in-ruby/120982 "2007-11-22T11:30:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [November 22, 2007, 11:30am UTC](https://www.ruby-forum.com/t/exceptions-in-ruby/120982/1 "2007-11-22T11:30:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [November 22, 2007, 12:29pm UTC](https://www.ruby-forum.com/t/exceptions-in-ruby/120982/2 "2007-11-22T12:29:53Z")

</div>

On Nov 22, 2007 11:30 AM, Martin D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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

```

> ```
> IOException
> 
> ```

```
              IOError

```

> ```
> EOFException
> 
> ```

```
             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
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Robert

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [November 22, 2007, 3:41pm UTC](https://www.ruby-forum.com/t/exceptions-in-ruby/120982/3 "2007-11-22T15:41:02Z")

</div>

On Nov 22, 2007, at 6:29 AM, Robert D. wrote:

> > ```
> > IllegalArgumentException
> > 
> > ```
> 
> ```
> ParameterError
> 
> ```

Are you sure you didn’t mean to write “ArgumentError”?

Regards, Morton

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [November 22, 2007, 3:54pm UTC](https://www.ruby-forum.com/t/exceptions-in-ruby/120982/4 "2007-11-22T15:54:02Z")

</div>

On Nov 22, 2007 3:40 PM, Morton G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On Nov 22, 2007, at 6:29 AM, Robert D. wrote:
> 
> > > ```
> > > IllegalArgumentException
> > > 
> > > ```
> > 
> > ```
> > ParameterError
> > 
> > ```
> 
> 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 ☹
