# Catch exception

**URL:** <https://www.ruby-forum.com/t/catch-exception/110841>\
**Category:** Rails\
**Created:** [July 31, 2007, 1:50pm UTC](https://www.ruby-forum.com/t/catch-exception/110841 "2007-07-31T13:50:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shafi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/439d5e/32.png) [@shafi](https://www.ruby-forum.com/u/shafi)\
**Post date:** [July 31, 2007, 1:50pm UTC](https://www.ruby-forum.com/t/catch-exception/110841/1 "2007-07-31T13:50:02Z")

</div>

hello guys

how to catch exceptions in RoR like java?

in java  
try{  
}  
catch(Exception c)  
{}

how to do that in RoR??  
thanks

---

<div class="post-metadata">

**Author:** ![shafi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/439d5e/32.png) [@shafi](https://www.ruby-forum.com/u/shafi)\
**Post date:** [July 31, 2007, 1:53pm UTC](https://www.ruby-forum.com/t/catch-exception/110841/2 "2007-07-31T13:53:29Z")

</div>

Look up the Ruby documentation for begin/rescue 🙂

---

<div class="post-metadata">

**Author:** ![shafi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/439d5e/32.png) [@shafi](https://www.ruby-forum.com/u/shafi)\
**Post date:** [July 31, 2007, 1:56pm UTC](https://www.ruby-forum.com/t/catch-exception/110841/3 "2007-07-31T13:56:29Z")

</div>

This is with java traduction (don’t know if it’s ok the java part 😉 )

begin # -\> try{  
raise “exception” # -\> throw new Exception();  
rescue # -\> }catch(Exception e){  
puts $! # -\> System.out.println(e.toString());  
end # -\> }

---

<div class="post-metadata">

**Author:** ![shafi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/439d5e/32.png) [@shafi](https://www.ruby-forum.com/u/shafi)\
**Post date:** [July 31, 2007, 2:11pm UTC](https://www.ruby-forum.com/t/catch-exception/110841/4 "2007-07-31T14:11:12Z")

</div>

good link:

[http://phrogz.net/ProgrammingRuby/tut\_exceptions.html](http://phrogz.net/ProgrammingRuby/tut_exceptions.html)

---

<div class="post-metadata">

**Author:** ![shafi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/439d5e/32.png) [@shafi](https://www.ruby-forum.com/u/shafi)\
**Post date:** [July 31, 2007, 2:28pm UTC](https://www.ruby-forum.com/t/catch-exception/110841/5 "2007-07-31T14:28:58Z")

</div>

thanks guys, it works successfully (Y)
