diff options
author | Zahary Karadjov <zahary@gmail.com> | 2012-09-29 18:39:18 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2012-10-03 01:59:49 +0300 |
commit | f8184e349027dc0273a3552526af18dc03df0f79 (patch) | |
tree | 22c2f728758b0c55803c92c8f5d70e1a7dded375 /compiler | |
parent | 698785ef5e560d533c6aec6b1f0e9125fb7afe2a (diff) | |
download | Nim-f8184e349027dc0273a3552526af18dc03df0f79.tar.gz |
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
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/msgs.nim | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 0ad79f597..c793c1c68 100755 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -575,19 +575,22 @@ proc inCheckpoint*(current: TLineInfo): TCheckPointResult = type TErrorHandling = enum doNothing, doAbort, doRaise -proc handleError(msg: TMsgKind, eh: TErrorHandling, s: string) = - if msg == errInternal: - assert(false) # we want a stack trace here +proc handleError(msg: TMsgKind, eh: TErrorHandling, s: string) = + template maybeTrace = + if defined(debug) or gVerbosity >= 3: + writeStackTrace() + + if msg == errInternal: + writeStackTrace() # we always want a stack trace here if msg >= fatalMin and msg <= fatalMax: - if gVerbosity >= 3: assert(false) + maybeTrace() quit(1) if msg >= errMin and msg <= errMax: - if gVerbosity >= 3: assert(false) + maybeTrace() inc(gErrorCounter) options.gExitcode = 1'i8 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: raiseRecoverableError(s) |