NLopt.jl icon indicating copy to clipboard operation
NLopt.jl copied to clipboard

Fix #156, exceptions from FORCED_STOP not rethrown

Open ikirill opened this issue 4 years ago • 4 comments

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.

ikirill avatar Jan 22 '21 09:01 ikirill

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.

ikirill avatar Jan 22 '21 09:01 ikirill

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?

BioTurboNick avatar May 10 '22 13:05 BioTurboNick

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.

ikirill avatar Aug 05 '22 09:08 ikirill

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.

ikirill avatar Aug 05 '22 09:08 ikirill

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 !

axsk avatar Dec 05 '22 14:12 axsk

@ikirill Any chance you've been working on this? It would be incredible to have this functionality.

gvnwst avatar Sep 11 '23 15:09 gvnwst

Closing in favor of #194

odow avatar Jan 15 '24 02:01 odow