diff --git a/src/webqueue2api/parser/parser.py b/src/webqueue2api/parser/parser.py index 0252e29..29af2f4 100644 --- a/src/webqueue2api/parser/parser.py +++ b/src/webqueue2api/parser/parser.py @@ -75,6 +75,17 @@ def parse_section(original_string: str, match_start_index: int, tokens: pp.Parse parsed_item.append(parse_error) raise ParseError(parse_error["line_num"], f"{parse_error['got']} is a malfomred header or the start of message content without a newline") + if "Date" not in headers.keys(): + content_start = tokens_dictionary["content"][0].strip().split("\n", 1)[0] + parse_error = { + "type": "parse_error", + "datetime": format_date_string(str(datetime.datetime.now())), + "expected": "A Date header in the reply from user section", + "got": content_start, + "line_num": original_string[:original_string.find(content_start)].count("\n") + 1 + } + raise ParseError(parse_error["line_num"], "Expected a 'Date' header in the reply from user section") + headers_list = [] for key in headers.keys(): headers_list.append({"type": key, "content": headers[key]})