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

StackFrame#from_exception should not fail with native java exceptions #105

Closed
wants to merge 5 commits into from
Closed

StackFrame#from_exception should not fail with native java exceptions #105

wants to merge 5 commits into from

Conversation

kowal
Copy link

@kowal kowal commented Jan 29, 2013

Currently on JRuby versions 1.6.8, 1.7.0, 1.7.1, 1.7.2, You can run into error:

undefined method `__better_errors_bindings_stack' for java.lang.Exception: oops:Java::JavaLang::Exception
     # ./lib/better_errors/stack_frame.rb:5:in `from_exception'

This is simple fix to not fail with undefined method. I've added missing method to all native java exceptions - for now it returns empty array, just to fallback to #backtrace in StackFrame#from_exception.

I also updated .gemspec work with jruby 1.6.8.

I'm not sure how to write specs for that kind of 'platform specific' features. Maybe it would be good idea to put them into separate file? Any suggestions are welcome.

@haileys
Copy link
Collaborator

haileys commented Feb 1, 2013

I'm not sure what I think of this to be honest. I would like to support all kinds of exceptions in all Ruby implementations, but it annoys me that java.lang.Exception objects don't behave like regular Exception objects in JRuby.

@kowal
Copy link
Author

kowal commented Feb 2, 2013

I think I made it more complicated than is actually is.

What I really wanted to fix in this PR is failing on missing __better_errors_bindings_stack. In order to do this, we can simply examine the exception with respond_to?. JRuby exceptions responds to backtrace, so 2nd condition in StackFrame#from_exception will work fine.

I'll update code tomorrow.

@kowal
Copy link
Author

kowal commented Feb 3, 2013

@charliesome please take a look at this now.

rvm 1.9.3,1.6.8,1.7.0,1.7.1,1.7.2 --verbose do rspec spec/ - all green.

You might have to install json gem for JRuby 1.6.8 - not sure if this should be included in .gemspec (I removed this change introduced in 1st PR version) as it's not required on latter versions anymore.

@haileys
Copy link
Collaborator

haileys commented Feb 7, 2013

You might have to install json gem for JRuby 1.6.8

json is in the standard library as of Ruby 1.9. If you're running JRuby in 1.9 mode, shouldn't json be present without having to use a gem?

@kowal
Copy link
Author

kowal commented Feb 7, 2013

I guess it is a bug in JRuby, however I can't find actual bug report for this.

When testing on 1.6.x I was getting LoadError for json (without 'json' gem installed)

rvm 1.7.0 do jruby -r rubygems -e "puts require('json')" # => true

rvm 1.6.8 do jruby --1.9 -r rubygems -e "puts require('json')"
LoadError: no such file to load -- json
  require at org/jruby/RubyKernel.java:1071
  ..

@kowal
Copy link
Author

kowal commented Feb 26, 2013

@charliesome - any updates for this issues?

@gioele
Copy link

gioele commented Jul 28, 2013

This problem still occurs with better_errors 0.9.0 and JRuby 1.7.4

@kowal
Copy link
Author

kowal commented Jul 29, 2013

@charliesome - any updates on this?

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

Successfully merging this pull request may close these issues.

3 participants