diff options
author | Miran <narimiran@disroot.org> | 2019-03-07 00:49:39 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-03-07 00:49:39 +0100 |
commit | 2b5e48d80735be60c68023de114a586bbcc18360 (patch) | |
tree | 4031d089c40c86339aa2a9b15b9f47840c473400 /lib/system/fatal.nim | |
parent | 26f48437ca429f8e25f20d1f986c5b46e83cc90b (diff) | |
download | Nim-2b5e48d80735be60c68023de114a586bbcc18360.tar.gz |
move assertions and iterators out of system.nim (#10597)
* move assertions and iterators out of system.nim * limit nimsuggest tests to the first 3 suggestions
Diffstat (limited to 'lib/system/fatal.nim')
-rw-r--r-- | lib/system/fatal.nim | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/system/fatal.nim b/lib/system/fatal.nim new file mode 100644 index 000000000..100b6d482 --- /dev/null +++ b/lib/system/fatal.nim @@ -0,0 +1,47 @@ +{.push profiler: off.} +when hostOS == "standalone": + include "$projectpath/panicoverride" + + proc sysFatal(exceptn: typedesc, message: string) {.inline.} = + panic(message) + + proc sysFatal(exceptn: typedesc, message, arg: string) {.inline.} = + rawoutput(message) + panic(arg) + +elif defined(nimQuirky) and not defined(nimscript): + proc name(t: typedesc): string {.magic: "TypeTrait".} + + proc sysFatal(exceptn: typedesc, message, arg: string) {.inline, noReturn.} = + var buf = newStringOfCap(200) + add(buf, "Error: unhandled exception: ") + add(buf, message) + add(buf, arg) + add(buf, " [") + add(buf, name exceptn) + add(buf, "]") + cstderr.rawWrite buf + quit 1 + + proc sysFatal(exceptn: typedesc, message: string) {.inline, noReturn.} = + sysFatal(exceptn, message, "") + +else: + proc sysFatal(exceptn: typedesc, message: string) {.inline, noReturn.} = + when declared(owned): + var e: owned(ref exceptn) + else: + var e: ref exceptn + new(e) + e.msg = message + raise e + + proc sysFatal(exceptn: typedesc, message, arg: string) {.inline, noReturn.} = + when declared(owned): + var e: owned(ref exceptn) + else: + var e: ref exceptn + new(e) + e.msg = message & arg + raise e +{.pop.} |