Skip to content

Add a field type for storing parsing defects #53

@jwodder

Description

@jwodder

Post #52:

Add a DefectsField field type for collecting errors raised during parsing and decoding

  • By default, errors are stored as a dict that maps header field names to lists of exceptions

    • What should happen for scanner and body errors?
      • Idea: Don't catch scanner errors … for now
      • Idea: Store them in the dict with the key set to a SCANNING or BODY enum or token
      • Idea: Wrap all decoder errors in custom DecoderError instances
        • Subclasses:
          • FieldDecoderError(post-alias-name, value, error)
          • ExtraFieldsDecoderError(value, error)
          • BodyDecoderError(value, error)
  • Non-extra fields can now take a required: bool parameter so that lack of a required field can be caught & registered as a defect

  • Errors are stored after calling .with_traceback(None) on them and their chain of causes (__cause__) & contexts (__context__) in order to reduce memory use

  • Should defects mode be toggleable by an option when parse*() is called?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions