##// 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 cmd = req.form['cmd'][0]
234 cmd = req.form['cmd'][0]
235
235
236 if cmd not in webcommands.__all__:
236 if cmd not in webcommands.__all__:
237 msg = 'No such method: %s' % cmd
237 msg = 'no such method: %s' % cmd
238 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
238 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
239 elif cmd == 'file' and 'raw' in req.form.get('style', []):
239 elif cmd == 'file' and 'raw' in req.form.get('style', []):
240 self.ctype = ctype
240 self.ctype = ctype
@@ -248,7 +248,11 b' class hgweb(object):'
248
248
249 except revlog.LookupError, err:
249 except revlog.LookupError, err:
250 req.respond(HTTP_NOT_FOUND, ctype)
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 except (RepoError, revlog.RevlogError), inst:
256 except (RepoError, revlog.RevlogError), inst:
253 req.respond(HTTP_SERVER_ERROR, ctype)
257 req.respond(HTTP_SERVER_ERROR, ctype)
254 req.write(tmpl('error', error=str(inst)))
258 req.write(tmpl('error', error=str(inst)))
@@ -737,7 +741,7 b' class hgweb(object):'
737 files[short] = (f, n)
741 files[short] = (f, n)
738
742
739 if not files:
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 def filelist(**map):
746 def filelist(**map):
743 fl = files.keys()
747 fl = files.keys()
@@ -34,10 +34,13 b' def rawfile(web, req, tmpl):'
34
34
35 try:
35 try:
36 fctx = web.filectx(req)
36 fctx = web.filectx(req)
37 except revlog.LookupError:
37 except revlog.LookupError, inst:
38 try:
38 content = web.manifest(tmpl, web.changectx(req), path)
39 content = web.manifest(tmpl, web.changectx(req), path)
39 req.respond(HTTP_OK, web.ctype)
40 req.respond(HTTP_OK, web.ctype)
40 return content
41 return content
42 except ErrorResponse:
43 raise inst
41
44
42 path = fctx.path()
45 path = fctx.path()
43 text = fctx.data()
46 text = fctx.data()
@@ -53,10 +56,13 b' def file(web, req, tmpl):'
53 if path:
56 if path:
54 try:
57 try:
55 return web.filerevision(tmpl, web.filectx(req))
58 return web.filerevision(tmpl, web.filectx(req))
56 except revlog.LookupError:
59 except revlog.LookupError, inst:
57 pass
60 pass
58
61
62 try:
59 return web.manifest(tmpl, web.changectx(req), path)
63 return web.manifest(tmpl, web.changectx(req), path)
64 except ErrorResponse:
65 raise inst
60
66
61 def changelog(web, req, tmpl, shortlog = False):
67 def changelog(web, req, tmpl, shortlog = False):
62 if 'node' in req.form:
68 if 'node' in req.form:
@@ -109,7 +115,7 b' def archive(web, req, tmpl):'
109 web.configbool("web", "allow" + type_, False))):
115 web.configbool("web", "allow" + type_, False))):
110 web.archive(tmpl, req, req.form['node'][0], type_)
116 web.archive(tmpl, req, req.form['node'][0], type_)
111 return []
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 def static(web, req, tmpl):
120 def static(web, req, tmpl):
115 fname = req.form['file'][0]
121 fname = req.form['file'][0]
@@ -27,6 +27,8 b' echo % should give a 400 - bad command'
27
27
28 echo % should give a 404 - file does not exist
28 echo % should give a 404 - file does not exist
29 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork?style=raw'
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 echo % stop and restart
33 echo % stop and restart
32 kill `cat hg.pid`
34 kill `cat hg.pid`
@@ -59,14 +59,49 b' error: revision not found: spam'
59 400
59 400
60
60
61
61
62 error: No such method: spam
62 error: no such method: spam
63 % should give a 404 - file does not exist
63 % should give a 404 - file does not exist
64 404 Not Found
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 % stop and restart
103 % stop and restart
69 7 log lines written
104 9 log lines written
70 % static file
105 % static file
71 200 Script output follows
106 200 Script output follows
72
107
@@ -5,7 +5,7 b' adding c'
5 404 Not Found
5 404 Not Found
6
6
7
7
8 error: Path not found: bork/
8 error: bork@8580ff50825a: not found in manifest
9 % should succeed
9 % should succeed
10 200 Script output follows
10 200 Script output follows
11
11
General Comments 0
You need to be logged in to leave comments. Login now