Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contracts messes up backtraces (stacktraces) #276

Open
md-work opened this issue Nov 30, 2017 · 0 comments
Open

Contracts messes up backtraces (stacktraces) #276

md-work opened this issue Nov 30, 2017 · 0 comments

Comments

@md-work
Copy link

md-work commented Nov 30, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant