summary refs log tree commit diff stats
path: root/tests/template/mtempl5.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/template/mtempl5.nim')
-rw-r--r--tests/template/mtempl5.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/template/mtempl5.nim b/tests/template/mtempl5.nim
index 3c2881764..2cc6f91bc 100644
--- a/tests/template/mtempl5.nim
+++ b/tests/template/mtempl5.nim
@@ -7,4 +7,18 @@ template templ*(): int =
   bind gx, gy
   gx + gy
 
+import json
+
+const
+  codeField = "foobar"
+  messageField = "more"
+
+template trap*(path: string, body: untyped): untyped =
+  #bind codeField, messageField
+  try:
+    body
+  except:
+    let msg = getCurrentExceptionMsg()
+    #debug "Error occurred within RPC ", path = path, errorMessage = msg
+    result = %*{codeField: "SERVER_ERROR", messageField: msg}