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.
Mohamed S. (Guest)
on 2007-07-31 15:50
hello guys

how to catch exceptions in RoR like java?

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

how to do that in RoR??
thanks
Cliff R. (Guest)
on 2007-07-31 15:53
(Received via mailing list)
Look up the Ruby documentation for begin/rescue :-)
Luis V. (Guest)
on 2007-07-31 15: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  # -> }
Shai R. (Guest)
on 2007-07-31 16:11
Mohamed S. (Guest)
on 2007-07-31 16:28
thanks guys, it works successfully (Y)
This topic is locked and can not be replied to.