Exception handling syntax: Difference between revisions

Content deleted Content added
Line 168:
 
===[[Ruby programming language|Ruby]]===
<source lang=ruby>
begin
# Do something nifty
raise SomeError, "This is the error message!" # Uh-oh!
rescue SomeError
rescue SomeError
# This is executed when a SomeError exception
# is raised
rescue AnotherError => error
# Here, the exception object is referenced from the
# `error' variable
else
# This is executed only if no exceptions were raised
ensure
# This is always executed, exception or not
end
</source>
 
===[[Python (programming language)|Python]]===