File tree Expand file tree Collapse file tree
wayang-api/wayang-api-json/src/main/scala Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ package org.apache.wayang.api.json
2020import zio ._
2121import zio .http ._
2222import scala .util .Try
23+ import java .io .{StringWriter , PrintWriter }
2324
2425import org .apache .wayang .api .json .builder .JsonPlanBuilder
2526import org .apache .wayang .api .json .operatorfromdrawflow .OperatorFromDrawflowConverter
@@ -61,8 +62,18 @@ object Main extends ZIOAppDefault {
6162 }
6263 resBody <- ZIO .succeed(Response .text(responseBody))
6364 } yield resBody).catchAll(t => {
64- t.printStackTrace
65- ZIO .succeed(Response .error(Status .BadRequest , t.getMessage))
65+ // Error messages printed in server
66+ t.printStackTrace
67+
68+ // Error messages sent to client
69+ val stringWriter = new StringWriter ()
70+ val printWriter = new PrintWriter (stringWriter)
71+ t.printStackTrace(printWriter)
72+ printWriter.flush()
73+ val fullErrorOutput = stringWriter.toString()
74+
75+ // Returns status code and the stacktrace (error message)
76+ ZIO .succeed(Response (status = Status .BadRequest , body = Body .fromString(fullErrorOutput)))
6677 })
6778 }
6879
You can’t perform that action at this time.
0 commit comments