Skip to content

Role of ErrorKind and intent of the variants? #697

@epage

Description

@epage

Some early expectations of ErrorKind from nom

  • Passed back through FFI to C APIs
  • iirc Infer intent from &[ErrorKind], inspired by another parser library (can't find where I saw this written)

Today in Winnow, none of these apply and the default error type drops ErrorKind. It is hard to infer intent from ErrorKind because which one is reported is an implementation detail in a lot of circumstances.

Also, ErrorKind variants are focused on what operation failed, instead of describing the failure

  • This is confusing (e.g. I keep wanting to use ErrorKind::Eof when an eof is found but its for when an eof isn't found)
  • It doesn't scale beyond built-in parsers and should not be used as a reason to add a built-in parser
  • AddContext can serve a similar role, though isn't applied to built-in parsers

Where should ErrorKind go?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-errorArea: error reportingC-questionUncertainty is involvedM-breaking-changeMeta: Implementing or merging this will introduce a breaking change.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions