Improve error messages
Fixes #246 (closed), #335 (closed), #337 (closed), #338 (closed), #339 (closed), #342 (closed).
Introduces contextual type and value errors that can be emitted by elements when they receive bad arguments in their constructor. These get caught by the parser and mapped back to KatScript. These have to be implemented in every KatScript-exposed component that performs type checking and value validation in their __init__
. As before, normal TypeError
and ValueError
exceptions still get handled by the parser but don't mark the components that are the problem, only the whole script line.
Lots of __init__
methods don't yet use these exceptions, so we've still got lots of work to do. Please continue to open issues for bad errors.
Also changed:
- Improved displayed errors when incorrect arguments are provided to Python constructors:
- Fixed counting issue for errors emitted by Python. Most constructors take
self
ormodel
and sometimesname
parameters. These are counted in Python's "function x takes 5 arguments but 6 were given" errors, but in KatScript these are not considered to be arguements so we have to subtract 1 or 2 depending on the constructor. - Markers point to extra arguments when too many are provided
- Markers highlight all arguments with clashing names when duplicates are provided
- Markers point to location where missing arguments should go
- Suggested syntax moved to after the displayed script error location
- Fixed counting issue for errors emitted by Python. Most constructors take
Edited by finesse importer