core/play/src/main/java/play/http/DefaultHttpErrorHandler.java
@Override
  public CompletionStage<Result> onServerError(RequestHeader request, Throwable exception) {
    try {
      UsefulException usefulException = throwableToUsefulException(exception);

      logServerError(request, usefulException);

      switch (environment.mode()) {
        case PROD:
          return onProdServerError(request, usefulException);
        default:
          return onDevServerError(request, usefulException);
      }
    } catch (Exception e) {
      logger.error("Error while handling error", e);
      return CompletableFuture.completedFuture(Results.internalServerError());
    }
  }
@Override
  public CompletionStage<Result> onServerError(RequestHeader request, Throwable exception) {
    try {
      UsefulException usefulException = throwableToUsefulException(exception);

      logServerError(request, usefulException);

      switch (environment.mode()) {
        case PROD:
          return onProdServerError(request, usefulException);
        default:
          return onDevServerError(request, usefulException);
      }
    } catch (Exception e) {
      logger.error("Error while handling error", e);
      return CompletableFuture.completedFuture(Results.internalServerError());
    }
  }
@ Override public CompletionStage < Result > onServerError ( RequestHeader request , Throwable exception ) { try { UsefulException usefulException = throwableToUsefulException ( exception ) ; logServerError ( request , usefulException ) ; switch ( environment . mode ( ) ) { case PROD : return onProdServerError ( request , usefulException ) ; default : return onDevServerError ( request , usefulException ) ; } } catch ( Exception e ) { logger . error ( "Error while handling error" , e ) ; return CompletableFuture . completedFuture ( Results . internalServerError ( ) ) ; } }
Invoked when a server error occurs.

<p>By default, the implementation of this method delegates to [[onProdServerError()]] when in
prod mode, and [[onDevServerError()]] in dev mode. It is recommended, if you want Play's debug
info on the error page in dev mode, that you override [[onProdServerError()]] instead of this
method.

@param request The request that triggered the server error.
@param exception The server error.
@return a CompletionStage containing the Result.
Invoked when a server error occurs .