Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'pry'
module SomeRecord
class Base
def do_something
raise self.class::NotFoundError.new
end
def self.inherited(subclass)
subclass.const_set :NotFoundError, Class.new(SomeRecord::NotFoundError)
end
end
class NotFoundError < StandardError
end
end
class MyClass < SomeRecord::Base
def do_something
puts "before error"
super
rescue NotFoundError
puts "in rescue"
raise
end
end
class User < SomeRecord::Base
end
# binding.pry
begin
MyClass.new.do_something
puts "did something, shouldn't see"
rescue MyClass::NotFoundError
puts "in outer rescue"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment