Skip to content

Instantly share code, notes, and snippets.

@gumayunov
Created May 14, 2014 11:00
Show Gist options
  • Save gumayunov/be52eedf042b5938a128 to your computer and use it in GitHub Desktop.
Save gumayunov/be52eedf042b5938a128 to your computer and use it in GitHub Desktop.
class NewMsisdnInUseError < Error;
def initialize(msg, models:)
super msg
@models = models
end
def inspect
Object.instance_method(:inspect).bind(self).call
end
end
[7] pry(main)> def foo
[7] pry(main)* raise MsisdnLifecycleService::NewMsisdnInUseError.new("231", models: [123])
[7] pry(main)* rescue Exception => e
[7] pry(main)* puts e.inspect
[7] pry(main)* puts e.backtrace
[7] pry(main)* end
=> :foo
[8] pry(main)> foo
#<MsisdnLifecycleService::NewMsisdnInUseError:0x007fae32234d70 @models=[123]>
(pry):16:in `foo'
(pry):21:in `<main>'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:328:in `eval'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:328:in `evaluate_ruby'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:278:in `re'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:254:in `rep'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:234:in `block (3 levels) in repl'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:232:in `loop'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:232:in `block (2 levels) in repl'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:231:in `catch'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:231:in `block in repl'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:230:in `catch'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:230:in `repl'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-0.9.12.2/lib/pry/pry_class.rb:170:in `start'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/pry-nav-0.2.3/lib/pry-nav/pry_ext.rb:17:in `start_with_pry_nav'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/railties-3.2.18/lib/rails/commands/console.rb:47:in `start'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/railties-3.2.18/lib/rails/commands/console.rb:8:in `start'
/Users/gumayunov/.rvm/gems/ruby-2.1.1@cnav/gems/railties-3.2.18/lib/rails/commands.rb:41:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment