Fixed server to return proper error messages

This commit is contained in:
Felix Krause 2023-03-13 22:52:59 +01:00
parent 034b9b8453
commit f6e09ebb6a
3 changed files with 14 additions and 11 deletions

View File

@ -72,7 +72,7 @@ task clean, "Remove all generated files":
task server, "Compile server daemon":
--d:release
--d:yamlScalarRepInd
--stackTrace
setCommand "c", "server/server"
task testSuiteEvents, "Compile the testSuiteEvents tool":

View File

@ -94,7 +94,7 @@
proc shareDir*(): string =
result = "$out/share"
EOF
${pkgs.nim}/bin/nim c --d:release --d:yamlScalarRepInd -p:"${nim-jester}/lib" -p:"${nim-httpbeast}/lib" -p:"${nim-cligen}/lib" --nimcache:.cache server/server
${pkgs.nim}/bin/nim c --d:release --stackTrace -p:"${nim-jester}/lib" -p:"${nim-httpbeast}/lib" -p:"${nim-cligen}/lib" --nimcache:.cache server/server
'';
installPhase = ''
mkdir -p $out/{bin,share}

View File

@ -28,6 +28,7 @@ router nyRouter:
of "json": style = psJson
of "block": style = psBlockOnly
of "tokens":
try:
var
output = "+STR\n"
parser = initYamlParser(false)
@ -37,6 +38,8 @@ router nyRouter:
resultNode["code"] = %0
resultNode["output"] = %output
msg = resultNode.pretty
except YamlStreamError as e:
raise e.parent
else:
retStatus = Http400
msg = "Invalid style: " & escape(@"style")