Skip to content

Commit

Permalink
Slightly improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Dec 8, 2024
1 parent a3e4df2 commit 4e3cdf0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/server/scintillate.HttpServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ case class HttpServer(port: Int)(using Tactic[ServerError]) extends RequestServa
val cancel: Promise[Unit] = Promise[Unit]()
val server = startServer()

val asyncTask = async(cancel.await() yet server.stop(1))
val asyncTask = async(cancel.attend() yet server.stop(1))

HttpService(port, asyncTask, () => safely(cancel.fulfill(())))

Expand Down
Binary file added src/servlet/.scintillate.JavaServlet.scala.swp
Binary file not shown.
7 changes: 5 additions & 2 deletions src/servlet/scintillate.JavaServlet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ open class JavaServlet(handle: HttpConnection ?=> HttpResponse) extends jsh.Http
HttpConnection(false, request.getServerPort, httpRequest, respond)

def handle(request: jsh.HttpServletRequest, response: jsh.HttpServletResponse): Unit =
safely:
unsafely:
val connection = makeConnection(request, response)
connection.respond(handle(using connection))

override def service(request: jsh.HttpServletRequest, response: jsh.HttpServletResponse): Unit =
handle(request, response)
try handle(request, response) catch
case error: Throwable =>
println("An error occurred while processing a request: "+error)
error.printStackTrace(System.out)

0 comments on commit 4e3cdf0

Please sign in to comment.