Commit e49019e2 authored by Mark Schouten's avatar Mark Schouten
Browse files

Improve loading of Yaml. Safer, and point to location of error

parent 8a47550b
#!/usr/bin/env python3
from yaml import load, dump
from yaml import safe_load, dump, YAMLError
from sys import exit
from copy import deepcopy
import re, socket
......@@ -13,7 +13,12 @@ def Get(cfg):
raise e
try:
document = load(f.read())
document = safe_load(f.read())
except YAMLError as exc:
if hasattr(exc, 'problem_mark'):
mark = exc.problem_mark
raise ValueError("YAML Error in configuration; Error on line %s, position %s)" \
% (mark.line+1, mark.column+1))
except:
raise ValueError("YAML Error in configuration")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment