mirror of https://github.com/status-im/NimYAML.git
allow echoing internal stacktrace if compiling with `d:debug`
`internalError` and `yAssert` now allow to echo the internal stack traces if the `d:debug` compile flag is set.
This commit is contained in:
parent
f0eeece22d
commit
db1a2c4041
|
@ -44,6 +44,8 @@ nim build # build a library
|
|||
NimYAML needs at least Nim 0.17.0 in order to compile. Version 0.9.1
|
||||
is the last release to support 0.15.x and 0.16.0.
|
||||
|
||||
When debugging crashes in this library, use the `d:debug` compile flag to enable printing of the internal stack traces for calls to `internalError` and `yAssert`.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][2]
|
||||
|
|
|
@ -5,16 +5,24 @@
|
|||
# distribution, for details about the copyright.
|
||||
|
||||
template internalError*(s: string) =
|
||||
# Note: to get the internal stacktrace that caused the error
|
||||
# compile with the `d:debug` flag.
|
||||
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()
|
||||
try:
|
||||
writeStackTrace()
|
||||
when defined(debug):
|
||||
echo "Internal stacktrace:"
|
||||
let exc = getCurrentException()
|
||||
echo getStackTrace(exc.parent)
|
||||
except: discard
|
||||
echo "[NimYAML] Please report this bug."
|
||||
quit 1
|
||||
|
||||
template yAssert*(e: typed) =
|
||||
when not defined(release):
|
||||
if not e:
|
||||
|
@ -23,7 +31,12 @@ template yAssert*(e: typed) =
|
|||
echo "assertion failed!"
|
||||
when not defined(JS):
|
||||
echo "[NimYAML] Stacktrace:"
|
||||
try: writeStackTrace()
|
||||
try:
|
||||
writeStackTrace()
|
||||
when defined(debug):
|
||||
echo "Internal stacktrace:"
|
||||
let exc = getCurrentException()
|
||||
echo getStackTrace(exc.parent)
|
||||
except: discard
|
||||
echo "[NimYAML] Please report this bug."
|
||||
quit 1
|
||||
|
|
Loading…
Reference in New Issue