Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# define an exception
class SillyError < Exception
end

View file

@ -0,0 +1,2 @@
class MyInvalidArgument < ArgumentError
end

View file

@ -0,0 +1,11 @@
# raise (throw) an exception
def spam
raise SillyError, 'egg'
end
# rescue (catch) an exception
begin
spam
rescue SillyError => se
puts se # writes 'egg' to stdout
end

View file

@ -0,0 +1,15 @@
begin
foo
rescue ArgumentError => e
# rescues a MyInvalidArgument or any other ArgumentError
bar
rescue => e
# rescues a StandardError
quack
else
# runs if no exception occurred
quux
ensure
# always runs
baz
end

View file

@ -0,0 +1,2 @@
# short way to rescue any StandardError
quotient = 1 / 0 rescue "sorry"

View file

@ -0,0 +1,7 @@
def foo
throw :done
end
catch :done do
foo
end