问题
In case there is a compilation or runtime issue in Play Framework, error is returned to the client on receiving HTTP request. Which part of Play Framework creates and send the HTML? Can I customize it? For eg., my code throws an Exception on application loading. I see the following page
I want to customize this page so that it looks/feels like website's page. Also, instead of HTML body, could I send a JSON body?
UPDATE Looking at the stack trace of my application, the application loading sequence seems to be
1) AkkaHttpServer.scala - calls val tryApp = applicationProvider.get
2) which calls case cl: ClassLoader => reload(cl) // New application classes in DevServerStart.scala
3) reload loads the application by calling loader.load but as my code throws an exception from there, it is caught by reload method.
Somewhere in the code execution, HttpErrorHandler's onDevServerError is called which uses the view views.html.defaultpages.devError. This view is hidden in IntelliJ. it is anyhow a read-only file, so I still can't figure out if it is possible for to customize this page. My other concern now is how the application will behave when I move to production mode.
来源:https://stackoverflow.com/questions/57431377/customize-the-error-page-from-play-framework