Skip to content

Instantly share code, notes, and snippets.

@chikoski
Created December 26, 2012 23:24
Show Gist options
  • Save chikoski/4383905 to your computer and use it in GitHub Desktop.
Save chikoski/4383905 to your computer and use it in GitHub Desktop.
class CustonException < StandardError
end
class CustonError < StandardError
end
def error_source(exception=true)
raise CustonException.new("Exception from error_source") if exception
raise CustonError.new("Error from error_source")
end
def error_handler(flag=true)
begin
error_source(flag)
rescue CustonException => e
puts "in exception_hander"
p e
ensure
puts "ensure clause in error_handler"
end
end
def error_relay(flag=true)
begin
error_source(flag)
rescue => e
puts "#{e} is relaied"
raise e
ensure
puts "ensure clause in error_relay"
end
end
begin
error_handler
error_handler(false)
rescue => e
puts "at global"
p e
end
begin
error_relay
rescue => e
puts "at global"
p e
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment