Show custom production error page only in Play

We want to override the default reproduction error page with our own error page. Unfortunately, the override onError

in our file Global

replaces the error page in all modes, although we would like to keep the debug error info page in development. How can I define a development mode to keep inline behavior in that mode?

+3


source to share


2 answers


The playback object has helper methods that allow you to check the 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)
  }
}

      

+3


source


Try the following:



if (play.api.Play.current.mode == play.api.Mode.Prod)
  ...

      

+2


source







All Articles