changeset 1554:68ec7b9e09a4

Catch IOErrors and RepoErrors when serving repositories via hgweb.
author Thomas Arendsen Hein <thomas@intevation.de>
date Thu, 17 Nov 2005 19:38:57 +0100
parents 4aeba581990b
children 01a5121a005a 59b3639df0a9
files mercurial/hgweb.py templates/error.tmpl templates/map
diffstat 3 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb.py
+++ b/mercurial/hgweb.py
@@ -1013,7 +1013,12 @@ class hgwebdir:
         if virtual:
             real = dict(self.repos).get(virtual)
             if real:
-                hgweb(real).run(req)
+                try:
+                    hgweb(real).run(req)
+                except IOError, inst:
+                    req.write(tmpl("error", error=inst.strerror))
+                except hg.RepoError, inst:
+                    req.write(tmpl("error", error=str(inst)))
             else:
                 req.write(tmpl("notfound", repo=virtual))
         else:
new file mode 100644
--- /dev/null
+++ b/templates/error.tmpl
@@ -0,0 +1,15 @@
+#header#
+<title>Mercurial Error</title>
+</head>
+<body>
+
+<h2>Mercurial Error</h2>
+
+<p>
+An error occured while processing your request:
+</p>
+<p>
+#error|escape#
+</p>
+
+#footer#
--- a/templates/map
+++ b/templates/map
@@ -39,3 +39,4 @@ indexentry = "<tr class="parity#parity#"
 index = index.tmpl
 archiveentry = "<a href="?ca=#node|short#;type=#type#">#type#</a> "
 notfound = notfound.tmpl
+error = error.tmpl