summary refs log tree commit diff stats
path: root/tests/template/mtempl5.nim
blob: 2cc6f91bc52ff08da26e03c17a657af2fcc630a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var
  gx = 88
  gy = 44

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}