On Mon, Apr 3, 2023 at 6:00 AM Sven Schreiber
<sven.schrei...@fu-berlin.de> wrote:
>
> I'm wondering why sometimes there exist informative error messages but it 
> doesn't seem easy to catch them. Here's a concrete (and real-world-inspired) 
> use case:
>
> ? m = feval("haha")
> haha: function not found
>
> That's exactly the right error message! However, now I try to retrieve that 
> programmatically:
>
> ? catch m = feval("haha")
> ? eval errmsg($error)
> Datenfehler # ( = data error)
>
> This is much less useful. Could the precise message be pushed through to the 
> error? Hm, I guess there aren't that many formally encoded error types...

The trouble is that an error caught by "catch" is by construction not
an error. When we're responding to errmsg($error) all we have to show
is the "boilerplate" message associated with the error code that was
set, then removed by "catch". But there may be a way to improve on
that...

> And BTW, here's a different and a little ironic example:
>
> ? m = I(2,3,4)
> I: zuviele Argumente    # (= too many arguments)
> ? catch m = I(2,3,4)
> I: zuviele Argumente
> ? eval errmsg($error)
> Befehl hat zu wenige Argumente # (= command with too *few* arguments)

OK, that was a case where the wrong internal error code, E_ARGS, was
set in a case of too many arguments; E_INVARG is now substituted, with
a generic message of "Invalid argument" (not very specific, but not
flat-out wrong).

Allin
_______________________________________________
Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it
To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it
Website: 
https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/

Reply via email to