eformat is called directly from the J interpreter:
https://github.com/jsoftware/jsource/blob/master/jsrc/d.c#L304
The eformat_j_ implementation is updated in step with the interpreter
itself, but written in J to simplify handling of a lot of the details.
It would probably make sense for addon code to supply its own error handling?
We can already signal multi-line error messages using the assert verb.
And, multi-line error messages are relatively easy to signal nowadays.
For example:
test assert~ {{)n
|Something went wrong.
|One clue is $1, and
|Another clue is $2.
}} rplc '$1';CLUE1;'$2';CLUE2
Though, of course, a real example should probably be more in line with
the patterns documented for eformat...
That said, I guess it would be nice for the statement which called the
library code be highlighted, and for that to appear above the error
message rather than below it. Maybe if we can come up with a clear
specification for that, it could be incorporated into a future release
of J? (I think, right now, the intent is to try and get j904 release
ready, which means at least temporarily discarding good ideas which we
might want later.)
Thanks,
--
Raul
On Tue, Feb 14, 2023 at 8:22 AM Jan-Pieter Jacobs
<[email protected]> wrote:
>
> Hi,
>
> I like the new, more explanatory error messages by dev/eformat.
> A while ago, I cooked up something far more ad-hoc, and doubtlessly less
> robust for the math/calculus addon, as I felt more wordy errors would help
> a user better.
>
> So now I wonder: is dev/eformat meant to (or could be extended to) allow
> addon owners to define error handling for their own addons (e.g.
> math/calculus)?
> If already possible, how would one use eformat? I took a cursory look at
> the script, but there is little information in the comments there.
>
> Thanks,
> Jan-Pieter
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm