Skip to content

Instantly share code, notes, and snippets.

@caius
Created December 6, 2023 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caius/59b8afa9e1917c706e59e04668bdb5ee to your computer and use it in GitHub Desktop.
Save caius/59b8afa9e1917c706e59e04668bdb5ee to your computer and use it in GitHub Desktop.
Error = Class.new(StandardError)
class Client
Error = Class.new(StandardError)
def call
raise "ZOMG"
rescue => e
raise Error.new("Uh oh #{e.inspect}")
end
end
begin
Client.new.call
rescue Client::Error => e
raise ::Error.new("Uh oh #{e.inspect}")
end
tmp/raise-cause.rb:16:in `rescue in <main>': Uh oh #<Client::Error: Uh oh #<RuntimeError: ZOMG>> (Error)
from tmp/raise-cause.rb:13:in `<main>'
tmp/raise-cause.rb:9:in `rescue in call': Uh oh #<RuntimeError: ZOMG> (Client::Error)
from tmp/raise-cause.rb:6:in `call'
from tmp/raise-cause.rb:14:in `<main>'
tmp/raise-cause.rb:7:in `call': ZOMG (RuntimeError)
from tmp/raise-cause.rb:14:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment