Exceptions

exception headerparser.errors.Error[source]

Bases: Exception

Superclass for all custom exceptions raised by the package

Parser Errors

exception headerparser.errors.ParserError[source]

Bases: Error, ValueError

Superclass for all custom exceptions related to errors in parsing

exception headerparser.errors.BodyNotAllowedError[source]

Bases: ParserError

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

exception headerparser.errors.DuplicateFieldError(name)[source]

Bases: ParserError

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

name

The name of the duplicated header field

exception headerparser.errors.FieldTypeError(name, value, exc_value)[source]

Bases: ParserError

Raised when a type callable raises an exception

exc_value

The exception raised by the type callable

name

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

value

The value on which the type callable was called

exception headerparser.errors.InvalidChoiceError(name, value)[source]

Bases: ParserError

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

name

The name of the header field

value

The invalid value

exception headerparser.errors.MissingBodyError[source]

Bases: ParserError

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

exception headerparser.errors.MissingFieldError(name)[source]

Bases: ParserError

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

name

The name of the missing header field

exception headerparser.errors.UnknownFieldError(name)[source]

Bases: ParserError

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

name

The name of the unknown header field

Scanner Errors

exception headerparser.errors.ScannerError[source]

Bases: Error, ValueError

Superclass for all custom exceptions related to errors in scanning

exception headerparser.errors.MalformedHeaderError(line)[source]

Bases: ScannerError

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

line

The invalid header line

exception headerparser.errors.UnexpectedFoldingError(line)[source]

Bases: ScannerError

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

line

The line containing the unexpected folding (indentation)