always print stack traces on errors in debug builds of nimrod
I've been using this for a while and it's really more convenient than hunting the message in msgs.nim and grepping the error code in the whole project
This commit is contained in:
parent
698785ef5e
commit
f8184e3490
1 changed files with 10 additions and 7 deletions
|
|
@ -576,17 +576,20 @@ type
|
||||||
TErrorHandling = enum doNothing, doAbort, doRaise
|
TErrorHandling = enum doNothing, doAbort, doRaise
|
||||||
|
|
||||||
proc handleError(msg: TMsgKind, eh: TErrorHandling, s: string) =
|
proc handleError(msg: TMsgKind, eh: TErrorHandling, s: string) =
|
||||||
|
template maybeTrace =
|
||||||
|
if defined(debug) or gVerbosity >= 3:
|
||||||
|
writeStackTrace()
|
||||||
|
|
||||||
if msg == errInternal:
|
if msg == errInternal:
|
||||||
assert(false) # we want a stack trace here
|
writeStackTrace() # we always want a stack trace here
|
||||||
if msg >= fatalMin and msg <= fatalMax:
|
if msg >= fatalMin and msg <= fatalMax:
|
||||||
if gVerbosity >= 3: assert(false)
|
maybeTrace()
|
||||||
quit(1)
|
quit(1)
|
||||||
if msg >= errMin and msg <= errMax:
|
if msg >= errMin and msg <= errMax:
|
||||||
if gVerbosity >= 3: assert(false)
|
maybeTrace()
|
||||||
inc(gErrorCounter)
|
inc(gErrorCounter)
|
||||||
options.gExitcode = 1'i8
|
options.gExitcode = 1'i8
|
||||||
if gErrorCounter >= gErrorMax or eh == doAbort:
|
if gErrorCounter >= gErrorMax or eh == doAbort:
|
||||||
if gVerbosity >= 3: assert(false)
|
|
||||||
quit(1) # one error stops the compiler
|
quit(1) # one error stops the compiler
|
||||||
elif eh == doRaise:
|
elif eh == doRaise:
|
||||||
raiseRecoverableError(s)
|
raiseRecoverableError(s)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue