mirror of https://github.com/status-im/NimYAML.git
fixes #90
This commit is contained in:
parent
f123924d32
commit
a72966374f
|
@ -15,13 +15,12 @@ template internalError*(s: string) =
|
||||||
echo "[NimYAML] Error in file ", ii.filename, " at line ", ii.line, ":"
|
echo "[NimYAML] Error in file ", ii.filename, " at line ", ii.line, ":"
|
||||||
echo s
|
echo s
|
||||||
when not defined(JS):
|
when not defined(JS):
|
||||||
echo "[NimYAML] Stacktrace:"
|
|
||||||
try:
|
try:
|
||||||
writeStackTrace()
|
var exc = getCurrentException()
|
||||||
let exc = getCurrentException()
|
while not isNil(exc):
|
||||||
if not isNil(exc.parent):
|
echo "… stacktrace [", exc.name, ": ", exc.msg, "]"
|
||||||
echo "Internal stacktrace:"
|
echo getStackTrace(exc)
|
||||||
echo getStackTrace(exc.parent)
|
exc = exc.parent
|
||||||
except: discard
|
except: discard
|
||||||
echo "[NimYAML] Please report this bug."
|
echo "[NimYAML] Please report this bug."
|
||||||
quit 1
|
quit 1
|
||||||
|
|
|
@ -1322,10 +1322,7 @@ proc construct*[T](s: var YamlStream, target: var T)
|
||||||
except YamlConstructionError:
|
except YamlConstructionError:
|
||||||
raise (ref YamlConstructionError)(getCurrentException())
|
raise (ref YamlConstructionError)(getCurrentException())
|
||||||
except YamlStreamError:
|
except YamlStreamError:
|
||||||
let cur = getCurrentException()
|
raise (ref YamlStreamError)(getCurrentException())
|
||||||
var e = newException(YamlStreamError, move(cur.msg))
|
|
||||||
e.parent = cur.parent
|
|
||||||
raise e
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# may occur while calling s()
|
# may occur while calling s()
|
||||||
var ex = newException(YamlStreamError, "")
|
var ex = newException(YamlStreamError, "")
|
||||||
|
@ -1335,11 +1332,11 @@ proc construct*[T](s: var YamlStream, target: var T)
|
||||||
proc load*[K](input: Stream | string, target: var K)
|
proc load*[K](input: Stream | string, target: var K)
|
||||||
{.raises: [YamlConstructionError, IOError, OSError, YamlParserError].} =
|
{.raises: [YamlConstructionError, IOError, OSError, YamlParserError].} =
|
||||||
## Loads a Nim value from a YAML character stream.
|
## Loads a Nim value from a YAML character stream.
|
||||||
|
try:
|
||||||
var
|
var
|
||||||
parser = initYamlParser()
|
parser = initYamlParser()
|
||||||
events = parser.parse(input)
|
events = parser.parse(input)
|
||||||
try:
|
e = events.next()
|
||||||
var e = events.next()
|
|
||||||
yAssert(e.kind == yamlStartStream)
|
yAssert(e.kind == yamlStartStream)
|
||||||
construct(events, target)
|
construct(events, target)
|
||||||
e = events.next()
|
e = events.next()
|
||||||
|
|
|
@ -97,6 +97,8 @@ proc next*(s: YamlStream): Event {.raises: [YamlStreamError], gcSafe.} =
|
||||||
try:
|
try:
|
||||||
while true:
|
while true:
|
||||||
if s.nextImpl(s, result): break
|
if s.nextImpl(s, result): break
|
||||||
|
except YamlStreamError:
|
||||||
|
raise (ref YamlStreamError)(getCurrentException())
|
||||||
except Exception:
|
except Exception:
|
||||||
let cur = getCurrentException()
|
let cur = getCurrentException()
|
||||||
var e = newException(YamlStreamError, cur.msg)
|
var e = newException(YamlStreamError, cur.msg)
|
||||||
|
|
Loading…
Reference in New Issue