Skip to content

Contracts messes up backtraces (stacktraces) #276

Description

@md-work

In general I'm very happy with Contracts and I don't want to miss it anymore. Nevertheless, there's one annoying problem. With Contracts in use backtraces (stacktraces) become quite messed up.

I know I can use the NO_CONTRACTS environment variable. But that's not always a practical solution, because I need to restart the application and reproduce whatever took me to the backtrace.


Example 1: Backtrace from Contract violation

/usr/lib64/ruby/gems/2.1.0/gems/contracts-0.16.0/lib/contracts.rb:49:in `block in <class:Contract>'
/usr/lib64/ruby/gems/2.1.0/gems/contracts-0.16.0/lib/contracts.rb:155:in `call'
/usr/lib64/ruby/gems/2.1.0/gems/contracts-0.16.0/lib/contracts.rb:155:in `failure_callback'
/usr/lib64/ruby/gems/2.1.0/gems/contracts-0.16.0/lib/contracts/method_handler.rb:143:in `rescue in block in redefine_method'
/usr/lib64/ruby/gems/2.1.0/gems/contracts-0.16.0/lib/contracts/method_handler.rb:136:in `block in redefine_method'
/home/user/mycode/app.rb:42:in `some_method_b'
[...]

Example 2: An exception in a method guided by a Contract

/home/user/mycode/app.rb:23:in `raise'
/home/user/mycode/app.rb:23:in `some_method_a'
/usr/lib64/ruby/gems/2.1.0/gems/contracts-0.16.0/lib/contracts/method_reference.rb:43:in `send_to'
/usr/lib64/ruby/gems/2.1.0/gems/contracts-0.16.0/lib/contracts/call_with.rb:79:in `call_with'
/usr/lib64/ruby/gems/2.1.0/gems/contracts-0.16.0/lib/contracts/method_handler.rb:138:in `block in redefine_method'
/home/user/mycode/app.rb:42:in `some_method_b'
[...]

Could you please look for a way to clean the backtrace from all lines with internal Contracts code?
E.g.: /usr/lib64/ruby/gems/2.1.0/gems/contracts-0.16.0/lib/contracts/method_handler.rb:138:in *`block in redefine_method'

If that's possible, an global option to enable/disable that backtrace cleaning would be wonderful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions