How to create custom compilation error pages in the play2.0 platform?

I want to customize the compilation error message page with my own error message.

How can i do this? Where will compilation error pages be displayed in playback mode 2.0?

Thanks in advance.

+4
source share
1 answer

It is best to create your own global object, overload onError (...) and display your own page, rather than the default.

Details can be found in the documentation here.

Given how useful the default error page is, I like to keep these errors during development and show something more convenient to produce. Thus, I usually do something like:

public class Global extends GlobalSettings { @Override public Result onError(Http.RequestHeader requestHeader, Throwable throwable) { if (Application.isDevelopment()) { return super.onError(requestHeader,throwable); } // customer facing Application.sendErrorEmail("Error occurred on production server: "+throwable.getMessage()); // give the customer a reasonable message without giving away any internal details return internalServerError("Sorry, but an unexpected error occurred. Please contact the administrator if this error continues."); } ... } 
+1
source

Source: https://habr.com/ru/post/1411916/


All Articles