xnd-project / libndtypes

Subsumed into xnd
https://xnd.io/
BSD 3-Clause "New" or "Revised" License
25 stars 17 forks source link

Improve error messages #47

Closed skrah closed 6 years ago

skrah commented 6 years ago

@pearu There were memcheck problems with 7c0f418c76. Apart from those, I wonder if we should always dump the whole string (which can be large) as part of the error message.

Let's think about it a bit.

skrah commented 6 years ago

I've added ndt_from_string_v() that uses verbose error messages in 8fc300424d9d7e53c4a875f7c8419005add504a0. It is also now used in gumath for kernel initialization.

So Python users still get the short error messages, which I prefer (one should get the line number in the traceback).

pearu commented 6 years ago

@skrah Short error messages with the information to problematic code (e.g. line number) is fine. However, when registering a bunch of kernels defined in C at the extension module import, the line number is not very informative (its equal to 1, iirc). So, could we include the name of the problematic kernel to the error message, at least? People are going to make mistakes when hand-writing kernel signatures and informative error messages can save debugging time for them. It saved for me, for instance.

skrah commented 6 years ago

@pearu ndt_from_string_v() (verbose) includes the signature, like you did in your err_append() function:

>>> from gumath import examples
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: 1:7: syntax error, unexpected FLOAT64, expecting RARROW: "N * M float64 -> P * float64"

We can go all the way and include the kernel name, too.