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 s
|
||||
when not defined(JS):
|
||||
echo "[NimYAML] Stacktrace:"
|
||||
try:
|
||||
writeStackTrace()
|
||||
let exc = getCurrentException()
|
||||
if not isNil(exc.parent):
|
||||
echo "Internal stacktrace:"
|
||||
echo getStackTrace(exc.parent)
|
||||
var exc = getCurrentException()
|
||||
while not isNil(exc):
|
||||
echo "… stacktrace [", exc.name, ": ", exc.msg, "]"
|
||||
echo getStackTrace(exc)
|
||||
exc = exc.parent
|
||||
except: discard
|
||||
echo "[NimYAML] Please report this bug."
|
||||
quit 1
|
||||
|
|
|
@ -1322,10 +1322,7 @@ proc construct*[T](s: var YamlStream, target: var T)
|
|||
except YamlConstructionError:
|
||||
raise (ref YamlConstructionError)(getCurrentException())
|
||||
except YamlStreamError:
|
||||
let cur = getCurrentException()
|
||||
var e = newException(YamlStreamError, move(cur.msg))
|
||||
e.parent = cur.parent
|
||||
raise e
|
||||
raise (ref YamlStreamError)(getCurrentException())
|
||||
except Exception:
|
||||
# may occur while calling s()
|
||||
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)
|
||||
{.raises: [YamlConstructionError, IOError, OSError, YamlParserError].} =
|
||||
## Loads a Nim value from a YAML character stream.
|
||||
try:
|
||||
var
|
||||
parser = initYamlParser()
|
||||
events = parser.parse(input)
|
||||
try:
|
||||
var e = events.next()
|
||||
e = events.next()
|
||||
yAssert(e.kind == yamlStartStream)
|
||||
construct(events, target)
|
||||
e = events.next()
|
||||
|
|
|
@ -97,6 +97,8 @@ proc next*(s: YamlStream): Event {.raises: [YamlStreamError], gcSafe.} =
|
|||
try:
|
||||
while true:
|
||||
if s.nextImpl(s, result): break
|
||||
except YamlStreamError:
|
||||
raise (ref YamlStreamError)(getCurrentException())
|
||||
except Exception:
|
||||
let cur = getCurrentException()
|
||||
var e = newException(YamlStreamError, cur.msg)
|
||||
|
|
Loading…
Reference in New Issue