Reputation: 36521
We want to override the standard Play error page with our own error page. Unfortunately, overriding onError
in our Global
file replaces the error page in all modes, even though we'd like to keep the informative debug error page in development. How can I detect development mode to retain the built-in behavior in that mode?
Upvotes: 3
Views: 267
Reputation: 14401
Play object has helper methods that allow checking a current application mode.
import play.api._
object Global extends GlobalSettings {
override def onError(request: RequestHeader, e: Throwable): Future[SimpleResult] = {
if (!Play.isDev)
Future.successful(InternalServerError(views.html.customErrorPage()))
else
super.onError(request, e)
}
}
Upvotes: 3