-
Notifications
You must be signed in to change notification settings - Fork 256
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
Return the actual Java Exception object on Exception? #203
Comments
FYI - That could be difficult to do. Might be possible, but no guarantees. However,
|
Yeah, I saw that, but I was hoping that we might be able to do better. I'm concerned that certain methods or data might be lost with just that approach. I might try to take a stab at some part of it, but my schedule is really packed for the next few weeks. |
Ah, I see what you're saying. You want access to the actual Java exception object, and we don't provide that. I'm sure that could be changed, I'm just not sure if we'll ever have native Python wrappers to allow catching specific Java exceptions. But we could probably have something like |
@kived Any further thoughts on this? I'd really like to be able to get a Java stacktrace. |
i didn't try it, but JavaException has a stacktrace attribute, that seems to be populated with a conversion of the java stacktrace, in check_exception() ? https://github.com/kivy/pyjnius/blob/master/jnius/jnius_utils.pxi#L91 that was already the case in 2016 when this bug was opened though, so there must be something i'm missing. |
Doesn't seem to be there:
prints:
Looking at jnius_utils.pxi, it isn't clear where this is thrown from. |
i would assume there which would mean the error didn't happen in java, it happened in python before the call to the java function, so there is no java stacktrace to report. edit: the latter part of the message (after "got {one}") was added in the latest version of pyjnius, released last weekend, which also solved some bugs in the lookup of methods, you might want to upgrade and try with that version. |
Got it - thanks! It would be nice if the message included the method name, since it must be known. I was able to print the stack trace with
and sorted it out. (The confusion was that the code had something like |
See also the discussion in #623 about how to better display the stack-trace. |
Hi!
Just wondering, I couldn't seem to be able to get the actual Java Exception object returned as an Exception? Is this by design, or is this something that could be part of future features?
For example, it would be nice to be able to do:
As an addendum, MyException would also have to inherit from jnius.JavaException
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/30741053-return-the-actual-java-exception-object-on-exception?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github).The text was updated successfully, but these errors were encountered: