Skip to content

Commit

Permalink
Merge pull request #282 from dapomeroy/schema_errors
Browse files Browse the repository at this point in the history
Update schema validation error message
  • Loading branch information
douglasjacobsen authored Oct 10, 2023
2 parents e86054e + 6fb061f commit 73db87d
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 73db87d

Please sign in to comment.