Fixed error reporting in server

This commit is contained in:
Felix Krause 2016-01-24 21:43:33 +01:00
parent daafa8b8e8
commit d7498f1c8a
1 changed files with 4 additions and 5 deletions

View File

@ -31,15 +31,14 @@ routes:
resultNode["code"] = %0
resultNode["output"] = %output.data
resp resultNode.pretty, "application/json"
except YamlPresenterStreamError:
let e = (ref YamlParserError)(getCurrentException().parent)
except YamlParserError:
let e = (ref YamlParserError)(getCurrentException())
resultNode["code"] = %1
resultNode["line"] = %e.line
resultNode["column"] = %e.column
resultNode["message"] = %e.msg
resultNode["detail"] = %e.lineContent
resp resultNode.pretty, "application/json"
except YamlPresenterJsonError:
let e = getCurrentException()
resultNode["code"] = %2
@ -48,8 +47,8 @@ routes:
resp resultNode.pretty, "application/json"
except:
let e = getCurrentException()
let msg = "Name: " & $e.name & "\nMessage: " & e.msg & "\nTrace:\n" &
e.getStackTrace
let msg = "Name: " & $e.name & "\nMessage: " & e.msg &
"\nTrace:\n" & e.getStackTrace
resp Http500, msg, "text/plain;charset=utf-8"
runForever()