mirror of https://github.com/status-im/NimYAML.git
Enhanced server errror reporting
This commit is contained in:
parent
433ec3f114
commit
9d708aa203
|
@ -28,25 +28,29 @@ routes:
|
|||
headers["Expires"] = "0"
|
||||
echo "INPUT: ", @"input", "STYLE:", @"style"
|
||||
try:
|
||||
try:
|
||||
transform(newStringStream(@"input"), output, style)
|
||||
resultNode["code"] = %0
|
||||
resultNode["output"] = %output.data
|
||||
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
|
||||
except YamlPresenterJsonError:
|
||||
let e = (ref YamlPresenterJsonError)(getCurrentException())
|
||||
resultNode["code"] = %2
|
||||
resultNode["message"] = %e.msg
|
||||
transform(newStringStream(@"input"), output, style)
|
||||
resultNode["code"] = %0
|
||||
resultNode["output"] = %output.data
|
||||
resp resultNode.pretty, "application/json"
|
||||
except YamlPresenterStreamError:
|
||||
let e = (ref YamlParserError)(getCurrentException().parent)
|
||||
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
|
||||
resultNode["message"] = %e.msg
|
||||
headers["Content-Type"] = "application/json"
|
||||
let s = resultNode.pretty
|
||||
resp s, "application/json"
|
||||
resp resultNode.pretty, "application/json"
|
||||
except:
|
||||
resp Http500, getCurrentException().repr, "text/plain;charset=utf-8"
|
||||
let e = getCurrentException()
|
||||
let msg = "Name: " & $e.name & "\nMessage: " & e.msg & "\nTrace:\n" &
|
||||
e.getStackTrace
|
||||
resp Http500, msg, "text/plain;charset=utf-8"
|
||||
|
||||
runForever()
|
||||
|
|
Loading…
Reference in New Issue