summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-06-10 18:43:34 -0400
committerJames Moger <james.moger@gitblit.com>2013-06-10 18:43:34 -0400
commit1078f80f6999d3a94ca47815a1d9fec471766b1d (patch)
tree659a549474b631b1da45887a69bbc7f491cdd1f5 /src/main/java/com/gitblit
parent1a8eb19b3cd55646adde33d922e8bc10f0090050 (diff)
downloadgitblit-1078f80f6999d3a94ca47815a1d9fec471766b1d.tar.gz
gitblit-1078f80f6999d3a94ca47815a1d9fec471766b1d.zip
Improve error handling within a repository page (issue-252)
Diffstat (limited to 'src/main/java/com/gitblit')
-rw-r--r--src/main/java/com/gitblit/wicket/GitBlitWebApp.properties3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BasePage.java32
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RepositoryPage.java3
3 files changed, 23 insertions, 15 deletions
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
index a278eff2..a5485ee2 100644
--- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
@@ -257,7 +257,7 @@ gb.repositoryNotSpecifiedFor = Repository not specified for {0}!
gb.canNotLoadRepository = Can not load repository
gb.commitIsNull = Commit is null
gb.unauthorizedAccessForRepository = Unauthorized access for repository
-gb.failedToFindCommit = Failed to find commit \"{0}\" in {1} for {2} page!
+gb.failedToFindCommit = Failed to find commit \"{0}\" in {1}!
gb.couldNotFindFederationProposal = Could not find federation proposal!
gb.invalidUsernameOrPassword = Invalid username or password!
gb.OneProposalToReview = There is 1 federation proposal awaiting review.
@@ -490,3 +490,4 @@ gb.failedToUpdateUser = Failed to update user account!
gb.myRepositories = my repositories
gb.noActivity = there has been no recent commit activity
gb.findSomeRepositories = find some repositories
+gb.metricAuthorExclusions = author metric exclusions \ No newline at end of file
diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.java b/src/main/java/com/gitblit/wicket/pages/BasePage.java
index 192f0122..71713cd9 100644
--- a/src/main/java/com/gitblit/wicket/pages/BasePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BasePage.java
@@ -32,9 +32,9 @@ import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import org.apache.wicket.Application;
+import org.apache.wicket.Page;
import org.apache.wicket.PageParameters;
import org.apache.wicket.RedirectToUrlException;
-import org.apache.wicket.RestartResponseException;
import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.ExternalLink;
@@ -333,22 +333,28 @@ public abstract class BasePage extends SessionPage {
}
public void error(String message, boolean redirect) {
- logger.error(message + " for " + GitBlitWebSession.get().getUsername());
- if (redirect) {
- GitBlitWebSession.get().cacheErrorMessage(message);
- String relativeUrl = urlFor(RepositoriesPage.class, null).toString();
- String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
- throw new RedirectToUrlException(absoluteUrl);
- } else {
- super.error(message);
- }
+ error(message, null, redirect ? getApplication().getHomePage() : null);
}
public void error(String message, Throwable t, boolean redirect) {
- logger.error(message, t);
- if (redirect) {
+ error(message, t, getApplication().getHomePage());
+ }
+
+ public void error(String message, Throwable t, Class<? extends Page> toPage) {
+ error(message, t, toPage, null);
+ }
+
+ public void error(String message, Throwable t, Class<? extends Page> toPage, PageParameters params) {
+ if (t == null) {
+ logger.error(message + " for " + GitBlitWebSession.get().getUsername());
+ } else {
+ logger.error(message + " for " + GitBlitWebSession.get().getUsername(), t);
+ }
+ if (toPage != null) {
GitBlitWebSession.get().cacheErrorMessage(message);
- throw new RestartResponseException(getApplication().getHomePage());
+ String relativeUrl = urlFor(toPage, params).toString();
+ String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
+ throw new RedirectToUrlException(absoluteUrl);
} else {
super.error(message);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
index fe509274..a15dd91b 100644
--- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
@@ -390,7 +390,8 @@ public abstract class RepositoryPage extends RootPage {
RevCommit commit = JGitUtils.getCommit(r, objectId);
if (commit == null) {
error(MessageFormat.format(getString("gb.failedToFindCommit"),
- objectId, repositoryName, getPageName()), true);
+ objectId, repositoryName, getPageName()), null, LogPage.class,
+ WicketUtils.newRepositoryParameter(repositoryName));
}
getSubmodules(commit);
return commit;