Fix #156, exceptions from FORCED_STOP not rethrown
It's not possible to rethrow outside a catch block (Julia gives an error). It was only checking for errors when ret was INVALID_ARGS which is wrong.
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.
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. I hope it works fine and will get merged, thank you for the work @ikirill !
@ikirill Any chance you've been working on this? It would be incredible to have this functionality.
Closing in favor of #194