As you all aware, the standard error page is like this ‘this exception has been logged with id XXXX’ , how can I show more detail messages, such as the message of exception and stack trace?
here upload a sample to elaborate my question, actually I want to show stack trace in this error page,could someone tell me how to make it?
Are you running this in production or in "dev mode"with
sbt run? In dev mode we show more information. In production it’s a security risk to show this information. But you can probably override the
HttpErrorHandler to change this behaviour.
Here’s the standard logic inside the
Thanks so much
Actually you don’t even need to override the
DefaultHttpErrorHandler. You can construct an error handler that always shows “development” errors as follows:
new DefaultHttpErrorHandler( HttpErrorConfig( showDevErrors = true, configuration.getOptional[String]("play.editor") ), sourceMapper, Some(router) )
If you are using runtime DI, you can also override the injected constructor (annotated with
@Inject) and change it to call the main constructor like above, then configure
play.http.errorHandler = com.example.MyDefaultHttpErrorHandler.
Just keep in mind that this is usually not something you want to do in a public production app. It can be a security risk to expose internal details like stack traces to untrusted users.