Created
December 26, 2012 23:24
-
-
Save chikoski/4383905 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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