Forum: Ruby on Rails Catch exception

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2366b35e3045fbee354edcbce654656b?d=identicon&s=25 Mohamed Saeed (mohamedsaeed)
on 2007-07-31 13:50
hello guys

how to catch exceptions in RoR like java?

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

how to do that in RoR??
thanks
0de2a19e1f26e4675d7dd363cc0157e9?d=identicon&s=25 Cliff Rowley (Guest)
on 2007-07-31 13:53
(Received via mailing list)
Look up the Ruby documentation for begin/rescue :-)
E91518f050cb6081186ff461950099e0?d=identicon&s=25 Luis Villegas (vilec)
on 2007-07-31 13:56
(Received via mailing list)
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  # -> }
4c3acdc3d93f54cc7a7281780ec8a4ee?d=identicon&s=25 Shai Rosenfeld (shai)
on 2007-07-31 14:11
2366b35e3045fbee354edcbce654656b?d=identicon&s=25 Mohamed Saeed (mohamedsaeed)
on 2007-07-31 14:28
thanks guys, it works successfully (Y)
This topic is locked and can not be replied to.