Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions wayang-api/wayang-api-json/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.apache.wayang.api.json
import zio._
import zio.http._
import scala.util.Try
import java.io.{StringWriter, PrintWriter}

import org.apache.wayang.api.json.builder.JsonPlanBuilder
import org.apache.wayang.api.json.operatorfromdrawflow.OperatorFromDrawflowConverter
Expand Down Expand Up @@ -61,8 +62,18 @@ object Main extends ZIOAppDefault {
}
resBody <- ZIO.succeed(Response.text(responseBody))
} yield resBody).catchAll(t => {
t.printStackTrace
ZIO.succeed(Response.error(Status.BadRequest, t.getMessage))
// Error messages printed in server
t.printStackTrace

// Error messages sent to client
val stringWriter = new StringWriter()
val printWriter = new PrintWriter(stringWriter)
t.printStackTrace(printWriter)
printWriter.flush()
val fullErrorOutput = stringWriter.toString()

// Returns status code and the stacktrace (error message)
ZIO.succeed(Response(status = Status.BadRequest, body = Body.fromString(fullErrorOutput)))
})
}

Expand Down
Loading