summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
author七秒不觉梦 <7822577+7sDream@users.noreply.github.com>2018-05-28 10:24:04 +0800
committerDmitry Atamanov <data-man@users.noreply.github.com>2018-05-28 05:24:04 +0300
commitb6b6382e0b4f86759d07a1be150a826b9e0fe054 (patch)
treec9af50e2ecdc6dc20a3f5613eaefe57295a89a76 /lib/pure
parent21fb0db6e271148e5c8970f0f9f4805bae2ca59a (diff)
downloadNim-b6b6382e0b4f86759d07a1be150a826b9e0fe054.tar.gz
Added: type name output when exception raised from unittest (#7869)
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/unittest.nim10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim
index 917251a6c..d804ba7c8 100644
--- a/lib/pure/unittest.nim
+++ b/lib/pure/unittest.nim
@@ -462,6 +462,8 @@ template suite*(name, body) {.dirty.} =
     finally:
       suiteEnded()
 
+template exceptionTypeName(e: typed): string = $e.name
+
 template test*(name, body) {.dirty.} =
   ## Define a single test case identified by `name`.
   ##
@@ -476,7 +478,7 @@ template test*(name, body) {.dirty.} =
   ## .. code-block::
   ##
   ##  [OK] roses are red
-  bind shouldRun, checkpoints, formatters, ensureInitialized, testEnded
+  bind shouldRun, checkpoints, formatters, ensureInitialized, testEnded, exceptionTypeName
 
   ensureInitialized()
 
@@ -495,8 +497,10 @@ template test*(name, body) {.dirty.} =
 
     except:
       when not defined(js):
-        checkpoint("Unhandled exception: " & getCurrentExceptionMsg())
-        var stackTrace {.inject.} = getCurrentException().getStackTrace()
+        let e = getCurrentException()
+        let eTypeDesc = "[" & exceptionTypeName(e) & "]"
+        checkpoint("Unhandled exception: " & getCurrentExceptionMsg() & " " & eTypeDesc)
+        var stackTrace {.inject.} = e.getStackTrace()
       fail()
 
     finally: