comparison mercurial/hgweb/hgweb_mod.py @ 6368:2c370f08c486

hgweb: better error messages
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Sun, 23 Mar 2008 23:08:18 +0100
parents cf1fa60fdaf4
children 31a01e3d99cc
comparison
equal deleted inserted replaced
6367:51984a2413f2 6368:2c370f08c486
232 if cmd == '': 232 if cmd == '':
233 req.form['cmd'] = [tmpl.cache['default']] 233 req.form['cmd'] = [tmpl.cache['default']]
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
241 content = webcommands.rawfile(self, req, tmpl) 241 content = webcommands.rawfile(self, req, tmpl)
242 else: 242 else:
246 req.write(content) 246 req.write(content)
247 del tmpl 247 del tmpl
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)))
255 except ErrorResponse, inst: 259 except ErrorResponse, inst:
256 req.respond(inst.code, ctype) 260 req.respond(inst.code, ctype)
735 else: 739 else:
736 short = os.path.basename(remain) 740 short = os.path.basename(remain)
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()
744 fl.sort() 748 fl.sort()
745 for f in fl: 749 for f in fl: