jiter icon indicating copy to clipboard operation
jiter copied to clipboard

Custom Python exception with `kind` and `path`

Open samuelcolvin opened this issue 1 year ago • 1 comments

We need a new exception that subclasses ValueError and adds a kind attribute which is the name from:

https://github.com/pydantic/jiter/blob/1fbedbfbcb86a767b9dd621d080f430528aebc33/crates/jiter/src/errors.rs#L6

and

https://github.com/pydantic/jiter/blob/1fbedbfbcb86a767b9dd621d080f430528aebc33/crates/jiter/src/errors.rs#L189

samuelcolvin avatar May 20 '24 19:05 samuelcolvin

We also want:

  • the path of the error, e.g. ['foo', 'bar', 0] - this should be opt in with (another) generic option, hopefully the last
  • the exact position of the error (as well as line and column number) this would allow the value that was rejected (e.g. NaN in the case of allow_nan_inf=False) to be extracted manually

samuelcolvin avatar May 27 '24 12:05 samuelcolvin