Boost logo

Boost Users :

From: Warren Weckesser (warren.weckesser_at_[hidden])
Date: 2022-04-14 14:29:10


On 4/14/22, John Maddock via Boost-users <boost-users_at_[hidden]> wrote:
>
>> That's actually a very good question, as things stand, I think the
>> only way you can know what the caller is, is to check the string name
>> passed to the error handler. It is possibly "worse" than that too as
>> some special functions can call other special functions internally, so
>> in a few rare cases, if something has gone badly wrong in the "outer"
>> function, the actual error may be generated in the "inner" function :(
>>
>> But leaving aside that issue for the moment, I would probably create a
>> sorted table of std::pair<const char* const char*>, with the first
>> member of the pair being our name, the second your name, and then do a
>> std:::lower_bound to find a matching entry and do the name
>> translation. I don't think our names have ever changed, so while
>> we've never guaranteed stability of those, it's hard to imagine them
>> changing unless someone spots a really grievous spelling mistake or
>> something ;) You would still need to perform the rather tedious job
>> of calling each function you're wrapping with say NaN parameters, and
>> then logging the string name of the function in the error handler so
>> you know what to put in the table.
>
> Maybe we're both over-thinking this, why not just:
>
> double erfinv_double(double x)
>
> {
>
> try{
>
> return erf_inv(x, special_policy());
>
> }
>
> catch(const std::domain_error&)
>
> {
>
> // Python error handling here.
>
> }
>
> catch(whatever-else-may-get-thrown){ /*more error handling*/}
>
> }
>
> ?

I had the same thought yesterday! That's what I'm doing in my latest
version of the wrapper.

Warren

>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net