From 28c6a3df01dcc66244300a1e1eb26f14a5d682f1 Mon Sep 17 00:00:00 2001 From: milessabin Date: Fri, 15 Mar 2024 16:57:39 +0000 Subject: [PATCH] deploy: 4c8740e65acb226276f22dd7a53076674c9ab0b1 --- tutorial/db-backed-model.html | 11 ++++++++++- tutorial/in-memory-model.html | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tutorial/db-backed-model.html b/tutorial/db-backed-model.html index a26355e0..8ac26026 100644 --- a/tutorial/db-backed-model.html +++ b/tutorial/db-backed-model.html @@ -466,13 +466,22 @@

val httpApp = Logger.httpApp(true, false)(httpApp0) + val withErrorLogging: HttpApp[IO] = ErrorHandling.Recover.total( + ErrorAction.log( + httpApp, + messageFailureLogAction = errorHandler, + serviceErrorLogAction = errorHandler)) + // Spin up the server ... EmberServerBuilder.default[IO] .withHost(ip"0.0.0.0") .withPort(port"8080") - .withHttpApp(httpApp) + .withHttpApp(withErrorLogging) .build.void } + + def errorHandler(t: Throwable, msg: => String) : IO[Unit] = + IO.println(msg) >> IO.println(t) >> IO.println(t.printStackTrace()) } diff --git a/tutorial/in-memory-model.html b/tutorial/in-memory-model.html index 95744ae4..2f484cfe 100644 --- a/tutorial/in-memory-model.html +++ b/tutorial/in-memory-model.html @@ -617,13 +617,22 @@

val httpApp = Logger.httpApp(true, false)(httpApp0) + val withErrorLogging: HttpApp[IO] = ErrorHandling.Recover.total( + ErrorAction.log( + httpApp, + messageFailureLogAction = errorHandler, + serviceErrorLogAction = errorHandler)) + // Spin up the server ... EmberServerBuilder.default[IO] .withHost(ip"0.0.0.0") .withPort(port"8080") - .withHttpApp(httpApp) + .withHttpApp(withErrorLogging) .build.void } + + def errorHandler(t: Throwable, msg: => String) : IO[Unit] = + IO.println(msg) >> IO.println(t) >> IO.println(t.printStackTrace()) }