Skip to content

Commit

Permalink
Update schema validation error message
Browse files Browse the repository at this point in the history
Add detail to make schema validation error message more useful.
  • Loading branch information
dapomeroy committed Oct 10, 2023
1 parent 56ec0fe commit 6fb061f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/ramble/ramble/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,14 +1336,17 @@ def __init__(self, validation_error, data, filename=None, line=None):

self.filename = filename # record this for ruamel.yaml

# construct location
# construct the location and retrieve the line that caused the error
location = '<unknown file>'
if filename:
location = '%s' % filename
location = f'{filename}'
if line is not None:
location += ':%d' % line
location += f':{line}'
with open(filename, 'r') as file:
lines = file.readlines()
location += f'\n{lines[mark.line]}'

message = '%s: %s' % (location, validation_error.message)
message = f'{location}\n{validation_error}'
super(ConfigError, self).__init__(message)

def _get_mark(self, validation_error, data):
Expand Down

0 comments on commit 6fb061f

Please sign in to comment.