]> source.dussan.org Git - gitblit.git/commitdiff
Improve error handling within a repository page (issue-252)
authorJames Moger <james.moger@gitblit.com>
Mon, 10 Jun 2013 22:43:34 +0000 (18:43 -0400)
committerJames Moger <james.moger@gitblit.com>
Mon, 10 Jun 2013 22:43:34 +0000 (18:43 -0400)
src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
src/main/java/com/gitblit/wicket/pages/BasePage.java
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java

index a278eff25a9951ca7c163edeb4dbd61408a418e0..a5485ee2ba9c6bd9a22dd0933039e2d2680dfbc0 100644 (file)
@@ -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
index 192f01220f9f7289cb534db1e47d1d171282b1d6..71713cd96920ee381b315524133cd2498e096013 100644 (file)
@@ -32,9 +32,9 @@ import java.util.regex.Pattern;
 import javax.servlet.http.HttpServletRequest;\r
 \r
 import org.apache.wicket.Application;\r
+import org.apache.wicket.Page;\r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.RedirectToUrlException;\r
-import org.apache.wicket.RestartResponseException;\r
 import org.apache.wicket.markup.html.CSSPackageResource;\r
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.link.ExternalLink;\r
@@ -333,22 +333,28 @@ public abstract class BasePage extends SessionPage {
        }\r
        \r
        public void error(String message, boolean redirect) {\r
-               logger.error(message  + " for " + GitBlitWebSession.get().getUsername());\r
-               if (redirect) {\r
-                       GitBlitWebSession.get().cacheErrorMessage(message);\r
-                       String relativeUrl = urlFor(RepositoriesPage.class, null).toString();\r
-                       String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);\r
-                       throw new RedirectToUrlException(absoluteUrl);\r
-               } else {\r
-                       super.error(message);\r
-               }\r
+               error(message, null, redirect ? getApplication().getHomePage() : null);\r
        }\r
 \r
        public void error(String message, Throwable t, boolean redirect) {\r
-               logger.error(message, t);\r
-               if (redirect) {\r
+               error(message, t, getApplication().getHomePage());\r
+       }\r
+       \r
+       public void error(String message, Throwable t, Class<? extends Page> toPage) {\r
+               error(message, t, toPage, null);\r
+       }\r
+       \r
+       public void error(String message, Throwable t, Class<? extends Page> toPage, PageParameters params) {\r
+               if (t == null) {\r
+                       logger.error(message  + " for " + GitBlitWebSession.get().getUsername());\r
+               } else {\r
+                       logger.error(message  + " for " + GitBlitWebSession.get().getUsername(), t);\r
+               }\r
+               if (toPage != null) {\r
                        GitBlitWebSession.get().cacheErrorMessage(message);\r
-                       throw new RestartResponseException(getApplication().getHomePage());\r
+                       String relativeUrl = urlFor(toPage, params).toString();\r
+                       String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);\r
+                       throw new RedirectToUrlException(absoluteUrl);\r
                } else {\r
                        super.error(message);\r
                }\r
index fe509274e49a7089cb0eb77084cd8e4cf152e5fd..a15dd91b63f3138378bbdb9a558386a4f5c15268 100644 (file)
@@ -390,7 +390,8 @@ public abstract class RepositoryPage extends RootPage {
                RevCommit commit = JGitUtils.getCommit(r, objectId);\r
                if (commit == null) {\r
                        error(MessageFormat.format(getString("gb.failedToFindCommit"),\r
-                                       objectId, repositoryName, getPageName()), true);\r
+                                       objectId, repositoryName, getPageName()), null, LogPage.class,\r
+                                       WicketUtils.newRepositoryParameter(repositoryName));\r
                }\r
                getSubmodules(commit);\r
                return commit;\r