Exceptions

exception headerparser.Error[source]

Bases: Exception

Superclass for all custom exceptions raised by the package

Parser Errors

exception headerparser.ParserError[source]

Bases: Error, ValueError

Superclass for all custom exceptions related to errors in parsing

exception headerparser.BodyNotAllowedError[source]

Bases: ParserError

Raised when body=False and the parser encounters a message body

exception headerparser.DuplicateFieldError(name: str)[source]

Bases: ParserError

Raised when a header field not marked as multiple occurs two or more times in the input

name: str

The name of the duplicated header field

exception headerparser.FieldTypeError(name: str, value: str, exc_value: BaseException)[source]

Bases: ParserError

Raised when a type callable raises an exception

exc_value: BaseException

The exception raised by the type callable

name: str

The name of the header field for which the type callable was called

value: str

The value on which the type callable was called

exception headerparser.InvalidChoiceError(name: str, value: Any)[source]

Bases: ParserError

Raised when a header field is given a value that is not one of its allowed choices

name: str

The name of the header field

value: Any

The invalid value

exception headerparser.MissingBodyError[source]

Bases: ParserError

Raised when body=True but there is no message body in the input

exception headerparser.MissingFieldError(name: str)[source]

Bases: ParserError

Raised when a header field marked as required is not present in the input

name: str

The name of the missing header field

exception headerparser.UnknownFieldError(name: str)[source]

Bases: ParserError

Raised when an unknown header field is encountered and additional header fields are not enabled

name: str

The name of the unknown header field

Scanner Errors

exception headerparser.ScannerError[source]

Bases: Error, ValueError

Superclass for all custom exceptions related to errors in scanning

exception headerparser.MalformedHeaderError(line: str)[source]

Bases: ScannerError

Raised when the scanner encounters an invalid header line, i.e., a line without either a colon or leading whitespace

line: str

The invalid header line

exception headerparser.UnexpectedFoldingError(line: str)[source]

Bases: ScannerError

Raised when the scanner encounters a folded (indented) line that is not preceded by a valid header line

line: str

The line containing the unexpected folding (indentation)

exception headerparser.ScannerEOFError[source]

Bases: Error

Raised when a Scanner method is called after all input has been exhausted