Re: How to forward a custom exception to Python

Lukáš Hrázký <[email protected]>
Newsgroups gmane.comp.programming.swig
Message-ID <[email protected]>
Hi Felix,

On Sat, 2020-02-01 at 12:57 +0100, Felix Salfelder wrote:
> On Fri, Jan 31, 2020 at 05:14:49PM +0100, Lukáš Hrázký wrote:
> ...
> 
> just some thoughts.
> 
> ...

Thanks for the multiple suggestions, at least I have options to
consider.

> > ...
> 
> Perhaps one way is to map your exceptions to the corresponding python
> style exceptions. eg raise a ValueError if some number is out of range,
> whichever way your library signals this.

Those standard exceptions have well-defined semantics and I need
something else. I can't use them.

> (not saying there is not a case for custom exceptions.)

Yes :) I'd like to stress this is probably the biggest point of my
email, custom exceptions are IMO simply _necessary_. Both my solutions
and your suggestions are very involved, potentially fragile and non-
transparent in case they break for a user of the library. At this stage
it is also not clear to me which solution to pick, as they kind of look
the same in the level of hackiness.

Therefore I'd like to get some sort of statement with regards to this
from the SWIG devs on the proper/recommended way or at least an opinion
on the state of things. The problem is obviously hard to solve, but I'd
still expect some sort of solution to this important aspect of wrapping
an API...

Thanks,
Lukas



_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.