Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Show appropriate message when database timeout occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
Yi EungJun committed Apr 1, 2015
1 parent 7b24f91 commit 9310254
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import views.html.welcome.secret;

import javax.annotation.Nonnull;
import javax.persistence.PersistenceException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -303,7 +304,13 @@ public Promise<Result> onError(RequestHeader request, Throwable t) {
AccessLogger.log(request, null, Http.Status.INTERNAL_SERVER_ERROR);

if (Play.isProd()) {
return Promise.pure((Result) Results.internalServerError(views.html.error.internalServerError_default.render("error.internalServerError")));
String messageKey;
if (t.getCause() instanceof PersistenceException && StringUtils.contains(t.getMessage(), "timed out")){
messageKey = "error.timeout";
} else {
messageKey = "error.internalServerError";
}
return Promise.pure((Result) Results.internalServerError(views.html.error.internalServerError_default.render(messageKey)));
} else {
return super.onError(request, t);
}
Expand Down
1 change: 1 addition & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ error.badrequest.only.available.for.git = This request is only supported in a gi
error.failedTo = Failed to {0}<br>({1} {2})
error.forbidden = You are not authorized
error.forbidden.or.notfound = Project not exists or unauthorized user
error.timeout = Your request could not be processed because of server timeout
error.internalServerError = Server error has occurred; service is not available
error.notfound = Page not found
error.notfound.board_post = Post not exists
Expand Down
1 change: 1 addition & 0 deletions conf/messages.ko-KR
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ error.badrequest.only.available.for.git = GIT 프로젝트에서만 지원하는
error.failedTo = {0}에 실패했습니다.<br>({1} {2})
error.forbidden = 권한이 없습니다
error.forbidden.or.notfound = 권한이 없거나 존재하지 않는 프로젝트입니다.
error.timeout = 요청 처리가 너무 오래 걸려 중단되었습니다
error.internalServerError = 서버 오류가 발생하여 서비스를 이용할 수 없습니다
error.notfound = 페이지를 찾을 수 없습니다
error.notfound.board_post = 존재하지 않는 글입니다
Expand Down

0 comments on commit 9310254

Please sign in to comment.