-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Stop wrapping Java exceptions with LoadError #5135
Comments
+1 have been using the native exception Java cause wrapping in RaiseException in a few places already. |
Yeah adding a cause to LoadError seems like a great way of preserving semantics of Ruby being able to deal with a failed load (a Java exception is just another novel one for us but not MRI), but still see the underlying problem. I would go so far to say an unhandled LoadError should display cause also. |
Well I can certainly add the cause, but it does not appear to be default behavior in CRuby to print the cause in the top-level exception printout. It's a start, but so far I am not seeing much default logging behavior associated with |
how about just using the Java |
(since |
@headius @kares So using cause may interfere with MRI future plans but I bet we could submit it since it sort of sucks to not know why something did not load. As far as not wanting to see this...It is quite rare an ordinary user would see this in the case of a Java Exception being the cause. Perhaps we can just display in that case. I suspect 99% of the time it is an ext developer or us. Most requires work or are a simple syntax error (which would be a Ruby exception not a Java one). |
Both CRuby and JRuby actually the actual exception for syntax errors and any regular Ruby errors that occur during load time. I'm not sure how to cause internal load errors in CRuby, so I can only test what happens when it can't find or load a file, which obviously leads to load errors. I should be clear...I'd like to just get rid of the wrapper altogether. If the Ruby code loads, everything that happens after that should just raise as a normal error. But I'm worried about libraries that use LoadError as a catch all around JRuby extensions or Java library calls, as an indication to fall back to pure-Ruby or a different version of the library. |
We will leave this unfixed for now. LoadError only wraps Java exceptions, allowing others to bubble out properly. This aligns (in my opinion) with MRI testing runtime-level failures in loading a library as more LoadError. |
In looking at #5115, I realized we are still wrapping Java exceptions that bubble through a
load
orrequire
with a newLoadError
. The only way to see the original exception is to pass-d
to JRuby and capture stderr so you can see the actual exception's stack trace.We need to do a better job reporting these exceptions, since they usually will indicate a load-time bug in some called library.
One option would be to set the
cause
of the LoadError to the Java exception, and make sure that exception dumping is outputting cause correctly. This should naturally then output the LoadError trace followed by the original Java exception trace.After thinking about it for a while, I do not believe we can stop wrapping them since the typical pattern in Ruby is that
rescue LoadError
covers a multitude of sins (library loading, library IO, other system exceptions during load). Any current libraries that depend on this behavior will continue to work as before. However, the logged output of those LoadError will now make it more obvious there's a problem to be fixed in the library itself.The text was updated successfully, but these errors were encountered: