-
Notifications
You must be signed in to change notification settings - Fork 47
Fix #156, exceptions from FORCED_STOP not rethrown #157
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
Conversation
|
This doesn't really fix the issue because there is no backtrace saved with the exception so it's a little useless the way this pr is. |
| if e !== nothing && !isa(e, ForcedStop) | ||
| nlopt_exception = nothing | ||
| rethrow(e) | ||
| throw(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too bad we lose the original stack trace; I guess in the future we could also potentially save the catch_backtrace() and wrap everything in our own exception type that shows this along with the original exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think wrapping the exception type might break try-catch blocks around the optimize call that expect specific exception types to be thrown.
I tried this: ikirill@c7aed00
|
I experienced this as well, would be really nice to just pass through the exception directly. However, if a custom exception type is needed to provide additional information, callers would probably be fine catching that and then inspecting the inner exception. What work is needed here? |
|
Sorry I forgot about this PR. I think it works, I've been using my own local NLopt and it throws exceptions with backtraces correctly. |
|
I also added saving backtraces to be shown with the exception. Obviously I can't rethrow the same exception, you have to save it from the function being called by C, and then throw it again on the Julia side once the C function returns. So maybe it's a little awkward. |
|
Just found this after haggling with debugging an error inside my objective without any stacktraces. |
|
@ikirill Any chance you've been working on this? It would be incredible to have this functionality. |
|
Closing in favor of #194 |
It's not possible to
rethrowoutside acatchblock (Julia gives an error). It was only checking for errors when ret was INVALID_ARGS which is wrong.