Catch exception


#1

hello guys

how to catch exceptions in RoR like java?

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

how to do that in RoR??
thanks


#2

Look up the Ruby documentation for begin/rescue :slight_smile:


#3

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

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


#4

good link:

http://phrogz.net/ProgrammingRuby/tut_exceptions.html


#5

thanks guys, it works successfully (Y)