NimYAML/yaml/private/internal.nim

38 lines
1.1 KiB
Nim
Raw Normal View History

2016-09-20 21:53:38 +02:00
# NimYAML - YAML implementation in Nim
# (c) Copyright 2016 Felix Krause
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
template internalError*(s: string) =
when not defined(release):
let ii = instantiationInfo()
echo "[NimYAML] Error in file ", ii.filename, " at line ", ii.line, ":"
echo s
when not defined(JS):
echo "[NimYAML] Stacktrace:"
try: writeStackTrace()
except: discard
echo "[NimYAML] Please report this bug."
quit 1
template yAssert*(e: typed) =
when not defined(release):
if not e:
let ii = instantiationInfo()
echo "[NimYAML] Error in file ", ii.filename, " at line ", ii.line, ":"
echo "assertion failed!"
when not defined(JS):
echo "[NimYAML] Stacktrace:"
try: writeStackTrace()
except: discard
echo "[NimYAML] Please report this bug."
quit 1
proc yamlTestSuiteEscape*(s: string): string =
result = ""
for c in s:
case c
of '\l': result.add("\\n")
of '\c': result.add("\\c")
of '\\': result.add("\\\\")
else: result.add(c)