Mercurial > hg
comparison mercurial/error.py @ 7633:08cabecfa8a8
errors: move revlog errors
- create error.py for exception classes to reduce demandloading
- move revlog exceptions to it
- change users to import error and drop revlog import if possible
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 11 Jan 2009 22:48:28 -0600 |
parents | |
children | e3f8c6d6b72e |
comparison
equal
deleted
inserted
replaced
7632:9626819b2e3d | 7633:08cabecfa8a8 |
---|---|
1 """ | |
2 error.py - Mercurial exceptions | |
3 | |
4 This allows us to catch exceptions at higher levels without forcing imports | |
5 | |
6 Copyright 2005-2008 Matt Mackall <mpm@selenic.com> | |
7 | |
8 This software may be used and distributed according to the terms | |
9 of the GNU General Public License, incorporated herein by reference. | |
10 """ | |
11 | |
12 # Do not import anything here, please | |
13 | |
14 class RevlogError(Exception): | |
15 pass | |
16 | |
17 class LookupError(RevlogError, KeyError): | |
18 def __init__(self, name, index, message): | |
19 self.name = name | |
20 if isinstance(name, str) and len(name) == 20: | |
21 from node import short | |
22 name = short(name) | |
23 RevlogError.__init__(self, '%s@%s: %s' % (index, name, message)) | |
24 | |
25 def __str__(self): | |
26 return RevlogError.__str__(self) |