Skip to content

Commit

Permalink
add component name to dto validation error message
Browse files Browse the repository at this point in the history
  • Loading branch information
frodehk committed Sep 12, 2023
1 parent 8be87dd commit a0e9f5e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import yaml
from libecalc.common.logger import logger
from libecalc.input.yaml_entities import Resource, YamlDict, YamlList
from libecalc.input.yaml_keywords import EcalcYamlKeywords
from yaml import Dumper, Mark

Loc = Tuple[Union[int, str], ...]
Expand Down Expand Up @@ -116,6 +117,7 @@ def __init__(
):
errors = validation_error.errors()

component_name = data[EcalcYamlKeywords.name]
messages = []
error_locs = []
try:
Expand All @@ -126,7 +128,7 @@ def __init__(
error_location_info = " -> ".join(
[str(s).capitalize().replace("__root__", "General error").replace("_", " ") for s in error_loc]
)
messages.append(f"{error_location_info}:\n\t{error_message}\n")
messages.append(f"{component_name} - {error_location_info}:\n\t{error_message}\n")
except Exception as e:
logger.debug(f"Failed to add location specific error messages: {str(e)}")

Expand Down

0 comments on commit a0e9f5e

Please sign in to comment.