diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/system.nim | 13 | ||||
-rwxr-xr-x | lib/system/excpt.nim | 6 |
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/system.nim b/lib/system.nim index 7a7a1c33b..1aa2732c1 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -1447,11 +1447,20 @@ var ## set this variable to provide a procedure that should be called before ## each executed instruction. This should only be used by debuggers! ## Only code compiled with the ``debugger:on`` switch calls this hook. - raiseHook*: proc (e: ref E_Base): bool + globalRaiseHook*: proc (e: ref E_Base): bool ## with this hook you can influence exception handling on a global level. ## If not nil, every 'raise' statement ends up calling this hook. Ordinary ## application code should never set this hook! You better know what you - ## do when setting this. If ``raiseHook`` returns false, the exception + ## do when setting this. If ``globalRaiseHook`` returns false, the + ## exception is caught and does not propagate further through the call + ## stack. + + localRaiseHook* {.threadvar.}: proc (e: ref E_Base): bool + ## with this hook you can influence exception handling on a + ## thread local level. + ## If not nil, every 'raise' statement ends up calling this hook. Ordinary + ## application code should never set this hook! You better know what you + ## do when setting this. If ``localRaiseHook`` returns false, the exception ## is caught and does not propagate further through the call stack. outOfMemHook*: proc diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index 2da768810..9593e3ebc 100755 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -194,8 +194,10 @@ proc quitOrDebug() {.inline.} = proc raiseException(e: ref E_Base, ename: CString) {.compilerRtl.} = e.name = ename - if raiseHook != nil: - if not raiseHook(e): return + if localRaiseHook != nil: + if not localRaiseHook(e): return + if globalRaiseHook != nil: + if not globalRaiseHook(e): return if excHandler != nil: pushCurrentException(e) c_longjmp(excHandler.context, 1) |