parent
0b3a45692c
commit
e7e9007c4c
1 changed files with 46 additions and 45 deletions
|
|
@ -1897,53 +1897,54 @@ else:
|
||||||
# however, stack-traces are available for most parts
|
# however, stack-traces are available for most parts
|
||||||
# of the code
|
# of the code
|
||||||
|
|
||||||
var
|
when notJSnotNims:
|
||||||
globalRaiseHook*: proc (e: ref Exception): bool {.nimcall, benign.}
|
var
|
||||||
## With this hook you can influence exception handling on a global level.
|
globalRaiseHook*: proc (e: ref Exception): bool {.nimcall, benign.}
|
||||||
## If not nil, every 'raise' statement ends up calling this hook.
|
## With this hook you can influence exception handling on a global level.
|
||||||
##
|
## If not nil, every 'raise' statement ends up calling this hook.
|
||||||
## **Warning**: Ordinary application code should never set this hook!
|
##
|
||||||
## You better know what you do when setting this.
|
## **Warning**: Ordinary application code should never set this hook!
|
||||||
##
|
## You better know what you do when setting this.
|
||||||
## If ``globalRaiseHook`` returns false, the exception is caught and does
|
##
|
||||||
## not propagate further through the call stack.
|
## If ``globalRaiseHook`` returns false, the exception is caught and does
|
||||||
|
## not propagate further through the call stack.
|
||||||
|
|
||||||
localRaiseHook* {.threadvar.}: proc (e: ref Exception): bool {.nimcall, benign.}
|
localRaiseHook* {.threadvar.}: proc (e: ref Exception): bool {.nimcall, benign.}
|
||||||
## With this hook you can influence exception handling on a
|
## With this hook you can influence exception handling on a
|
||||||
## thread local level.
|
## thread local level.
|
||||||
## If not nil, every 'raise' statement ends up calling this hook.
|
## If not nil, every 'raise' statement ends up calling this hook.
|
||||||
##
|
##
|
||||||
## **Warning**: Ordinary application code should never set this hook!
|
## **Warning**: Ordinary application code should never set this hook!
|
||||||
## You better know what you do when setting this.
|
## You better know what you do when setting this.
|
||||||
##
|
##
|
||||||
## If ``localRaiseHook`` returns false, the exception
|
## If ``localRaiseHook`` returns false, the exception
|
||||||
## is caught and does not propagate further through the call stack.
|
## is caught and does not propagate further through the call stack.
|
||||||
|
|
||||||
outOfMemHook*: proc () {.nimcall, tags: [], benign, raises: [].}
|
outOfMemHook*: proc () {.nimcall, tags: [], benign, raises: [].}
|
||||||
## Set this variable to provide a procedure that should be called
|
## Set this variable to provide a procedure that should be called
|
||||||
## in case of an `out of memory`:idx: event. The standard handler
|
## in case of an `out of memory`:idx: event. The standard handler
|
||||||
## writes an error message and terminates the program.
|
## writes an error message and terminates the program.
|
||||||
##
|
##
|
||||||
## `outOfMemHook` can be used to raise an exception in case of OOM like so:
|
## `outOfMemHook` can be used to raise an exception in case of OOM like so:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
##
|
##
|
||||||
## var gOutOfMem: ref EOutOfMemory
|
## var gOutOfMem: ref EOutOfMemory
|
||||||
## new(gOutOfMem) # need to be allocated *before* OOM really happened!
|
## new(gOutOfMem) # need to be allocated *before* OOM really happened!
|
||||||
## gOutOfMem.msg = "out of memory"
|
## gOutOfMem.msg = "out of memory"
|
||||||
##
|
##
|
||||||
## proc handleOOM() =
|
## proc handleOOM() =
|
||||||
## raise gOutOfMem
|
## raise gOutOfMem
|
||||||
##
|
##
|
||||||
## system.outOfMemHook = handleOOM
|
## system.outOfMemHook = handleOOM
|
||||||
##
|
##
|
||||||
## If the handler does not raise an exception, ordinary control flow
|
## If the handler does not raise an exception, ordinary control flow
|
||||||
## continues and the program is terminated.
|
## continues and the program is terminated.
|
||||||
unhandledExceptionHook*: proc (e: ref Exception) {.nimcall, tags: [], benign, raises: [].}
|
unhandledExceptionHook*: proc (e: ref Exception) {.nimcall, tags: [], benign, raises: [].}
|
||||||
## Set this variable to provide a procedure that should be called
|
## Set this variable to provide a procedure that should be called
|
||||||
## in case of an `unhandle exception` event. The standard handler
|
## in case of an `unhandle exception` event. The standard handler
|
||||||
## writes an error message and terminates the program, except when
|
## writes an error message and terminates the program, except when
|
||||||
## using `--os:any`
|
## using `--os:any`
|
||||||
|
|
||||||
type
|
type
|
||||||
PFrame* = ptr TFrame ## Represents a runtime frame of the call stack;
|
PFrame* = ptr TFrame ## Represents a runtime frame of the call stack;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue