Skip to content

Commit

Permalink
Adds detailed explanation and doc link for the default ExceptionHandl…
Browse files Browse the repository at this point in the history
…er log message on NonFatal: akka#887
  • Loading branch information
tkroman committed Feb 22, 2017
1 parent 691a56c commit ad5987c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ object ExceptionHandler {
ctx.complete((status, info.format(settings.verboseErrorMessages)))
}
case NonFatal(e) ctx {
ctx.log.error("Error during processing of request: '{}'. Completing with {} response.", e.getMessage, InternalServerError)
val message = Option(e.getMessage).getOrElse(s"${e.getClass.getName} (No error message supplied)")
val template =
s"""Error during processing of request: '{}'.
|Completing with {} response.
|Stack traces aren't printed by default.
|To customize this behavior, consider implementing a custom ExceptionHandler
|(http://doc.akka.io/docs/akka-http/current/scala/http/routing-dsl/exception-handling.html)"""
.stripMargin
ctx.log.error(template, message, InternalServerError)
ctx.complete(InternalServerError)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class HttpAppExampleSpec extends WordSpec with Matchers
import akka.http.scaladsl.model.{ ContentTypes, HttpEntity }
import akka.http.scaladsl.server.HttpApp
import akka.http.scaladsl.server.Route

// Server definition
object WebServer extends HttpApp {
def route: Route =
Expand Down

0 comments on commit ad5987c

Please sign in to comment.