Skip to content

Commit 9d6f8d4

Browse files
committed
simpler error messages
1 parent b0699e8 commit 9d6f8d4

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

plain_file.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def check_if_functional_requirements_are_specified(plain_source, non_functional_
136136

137137
found_functional_requirements = plain_spec.FUNCTIONAL_REQUIREMENTS in plain_source
138138
if found_functional_requirements and len(non_functional_requirements) == 0:
139-
raise PlainSyntaxError("Plain syntax error: Syntax error: functionality with no implementation reqs specified.")
139+
raise PlainSyntaxError("Plain syntax error: functionality with no implementation reqs specified.")
140140

141141
return found_functional_requirements
142142

@@ -348,7 +348,7 @@ def process_imports(
348348
for specification_heading in plain_file_parse_result.plain_source:
349349
if specification_heading not in plain_spec.ALLOWED_IMPORT_SPECIFICATION_HEADINGS:
350350
raise PlainSyntaxError(
351-
f"Plain syntax error: Syntax error: Invalid specification heading (`{specification_heading}`). Allowed headings: {', '.join(plain_spec.ALLOWED_IMPORT_SPECIFICATION_HEADINGS)}"
351+
f"Plain syntax error: Invalid specification heading (`{specification_heading}`). Allowed headings: {', '.join(plain_spec.ALLOWED_IMPORT_SPECIFICATION_HEADINGS)}"
352352
)
353353

354354
if plain_source[specification_heading] is None:
@@ -377,7 +377,7 @@ def read_plain_source_metadata(plain_source_text):
377377
try:
378378
plain_source_obj = frontmatter.loads(plain_source_text)
379379
except Exception as e:
380-
raise PlainSyntaxError(f"Plain syntax error: Syntax error: Invalid frontmatter: {e}")
380+
raise PlainSyntaxError(f"Plain syntax error: Invalid frontmatter: {e}")
381381

382382
for directive in [EXPORTED_CONCEPTS_DIRECTIVE, REQUIRED_CONCEPTS_DIRECTIVE]:
383383
if directive in plain_source_obj.metadata:
@@ -393,7 +393,7 @@ def read_plain_source_metadata(plain_source_text):
393393
prepared_metadata.append(f"- {item}")
394394
else:
395395
raise PlainSyntaxError(
396-
f"Plain syntax error: Syntax error: Invalid {directive} metadata. Expected a dictionary or a string."
396+
f"Plain syntax error: Invalid {directive} metadata. Expected a dictionary or a string."
397397
)
398398

399399
plain_source_obj.metadata[directive] = prepared_metadata
@@ -576,13 +576,13 @@ def process_required_modules(
576576
for concept in plain_file_parse_result.plain_source_obj.metadata[EXPORTED_CONCEPTS_DIRECTIVE]:
577577
if concept in concept_utils.DEFAULT_CONCEPTS:
578578
raise PlainSyntaxError(
579-
f"Plain syntax error: Syntax error: Default concept cannot be exported: {concept}. Only user-defined concepts can be exported."
579+
f"Plain syntax error: Default concept cannot be exported: {concept}. Only user-defined concepts can be exported."
580580
)
581581

582582
if isinstance(concept, str):
583583
exported_concepts.extend(concept_utils.extract_concepts_from_definition(concept)[0])
584584
else:
585-
raise PlainSyntaxError(f"Plain syntax error: Syntax error: Invalid exported concept: {concept}.")
585+
raise PlainSyntaxError(f"Plain syntax error: Invalid exported concept: {concept}.")
586586

587587
with PlainRenderer() as renderer:
588588
for exported_concept in exported_concepts:
@@ -645,11 +645,13 @@ def plain_file_parser( # noqa: C901
645645
missing_required_concepts_msg = "Missing required concepts: "
646646
missing_required_concepts_msg += ", ".join(plain_file_parse_result.required_concepts)
647647
raise PlainSyntaxError(
648-
f"Plain syntax error: Syntax error: Not all required concepts were defined. {missing_required_concepts_msg}."
648+
f"Plain syntax error: Not all required concepts were defined. {missing_required_concepts_msg}."
649649
)
650650

651651
if not check_if_functional_requirements_are_specified(plain_file_parse_result.plain_source, []):
652-
raise PlainSyntaxError("Plain syntax error: Syntax error: No functionality specified.")
652+
raise PlainSyntaxError(
653+
f"Plain syntax error: Module '{module_name}' was required but does not contain functional requirements."
654+
)
653655

654656
exported_definitions = process_required_modules(
655657
plain_file_parse_result.required_modules,

0 commit comments

Comments
 (0)