##// END OF EJS Templates
hgweb: better error messages
Dirkjan Ochtman -
r6368:2c370f08 default
parent child Browse files
Show More
@@ -234,7 +234,7 b' class hgweb(object):'
234 234 cmd = req.form['cmd'][0]
235 235
236 236 if cmd not in webcommands.__all__:
237 msg = 'No such method: %s' % cmd
237 msg = 'no such method: %s' % cmd
238 238 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
239 239 elif cmd == 'file' and 'raw' in req.form.get('style', []):
240 240 self.ctype = ctype
@@ -248,7 +248,11 b' class hgweb(object):'
248 248
249 249 except revlog.LookupError, err:
250 250 req.respond(HTTP_NOT_FOUND, ctype)
251 req.write(tmpl('error', error='revision not found: %s' % err.name))
251 if 'manifest' in err.message:
252 msg = str(err)
253 else:
254 msg = 'revision not found: %s' % err.name
255 req.write(tmpl('error', error=msg))
252 256 except (RepoError, revlog.RevlogError), inst:
253 257 req.respond(HTTP_SERVER_ERROR, ctype)
254 258 req.write(tmpl('error', error=str(inst)))
@@ -737,7 +741,7 b' class hgweb(object):'
737 741 files[short] = (f, n)
738 742
739 743 if not files:
740 raise ErrorResponse(HTTP_NOT_FOUND, 'Path not found: ' + path)
744 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
741 745
742 746 def filelist(**map):
743 747 fl = files.keys()
@@ -34,10 +34,13 b' def rawfile(web, req, tmpl):'
34 34
35 35 try:
36 36 fctx = web.filectx(req)
37 except revlog.LookupError:
38 content = web.manifest(tmpl, web.changectx(req), path)
39 req.respond(HTTP_OK, web.ctype)
40 return content
37 except revlog.LookupError, inst:
38 try:
39 content = web.manifest(tmpl, web.changectx(req), path)
40 req.respond(HTTP_OK, web.ctype)
41 return content
42 except ErrorResponse:
43 raise inst
41 44
42 45 path = fctx.path()
43 46 text = fctx.data()
@@ -53,10 +56,13 b' def file(web, req, tmpl):'
53 56 if path:
54 57 try:
55 58 return web.filerevision(tmpl, web.filectx(req))
56 except revlog.LookupError:
59 except revlog.LookupError, inst:
57 60 pass
58 61
59 return web.manifest(tmpl, web.changectx(req), path)
62 try:
63 return web.manifest(tmpl, web.changectx(req), path)
64 except ErrorResponse:
65 raise inst
60 66
61 67 def changelog(web, req, tmpl, shortlog = False):
62 68 if 'node' in req.form:
@@ -109,7 +115,7 b' def archive(web, req, tmpl):'
109 115 web.configbool("web", "allow" + type_, False))):
110 116 web.archive(tmpl, req, req.form['node'][0], type_)
111 117 return []
112 raise ErrorResponse(HTTP_NOT_FOUND, 'Unsupported archive type: %s' % type_)
118 raise ErrorResponse(HTTP_NOT_FOUND, 'unsupported archive type: %s' % type_)
113 119
114 120 def static(web, req, tmpl):
115 121 fname = req.form['file'][0]
@@ -27,6 +27,8 b' echo % should give a 400 - bad command'
27 27
28 28 echo % should give a 404 - file does not exist
29 29 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork?style=raw'
30 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork'
31 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/bork?style=raw'
30 32
31 33 echo % stop and restart
32 34 kill `cat hg.pid`
@@ -59,14 +59,49 b' error: revision not found: spam'
59 59 400
60 60
61 61
62 error: No such method: spam
62 error: no such method: spam
63 63 % should give a 404 - file does not exist
64 64 404 Not Found
65 65
66 66
67 error: Path not found: bork/
67 error: bork@2ef0ac749a14: not found in manifest
68 404 Not Found
69
70 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
71 <html>
72 <head>
73 <link rel="icon" href="/static/hgicon.png" type="image/png">
74 <meta name="robots" content="index, nofollow" />
75 <link rel="stylesheet" href="/static/style.css" type="text/css" />
76
77 <title>Mercurial Error</title>
78 </head>
79 <body>
80
81 <h2>Mercurial Error</h2>
82
83 <p>
84 An error occurred while processing your request:
85 </p>
86 <p>
87 bork@2ef0ac749a14: not found in manifest
88 </p>
89
90
91 <div class="logo">
92 <a href="http://www.selenic.com/mercurial/">
93 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
94 </div>
95
96 </body>
97 </html>
98
99 404 Not Found
100
101
102 error: bork@2ef0ac749a14: not found in manifest
68 103 % stop and restart
69 7 log lines written
104 9 log lines written
70 105 % static file
71 106 200 Script output follows
72 107
@@ -5,7 +5,7 b' adding c'
5 5 404 Not Found
6 6
7 7
8 error: Path not found: bork/
8 error: bork@8580ff50825a: not found in manifest
9 9 % should succeed
10 10 200 Script output follows
11 11
General Comments 0
You need to be logged in to leave comments. Login now