##// END OF EJS Templates
error: introduce StorageError...
Gregory Szorc -
r39812:cb65d4b7 default
parent child Browse files
Show More
@@ -34,7 +34,14 b' class Hint(object):'
34 34 self.hint = kw.pop(r'hint', None)
35 35 super(Hint, self).__init__(*args, **kw)
36 36
37 class RevlogError(Hint, Exception):
37 class StorageError(Hint, Exception):
38 """Raised when an error occurs in a storage layer.
39
40 Usually subclassed by a storage-specific exception.
41 """
42 __bytes__ = _tobytes
43
44 class RevlogError(StorageError):
38 45 __bytes__ = _tobytes
39 46
40 47 class FilteredIndexError(IndexError):
@@ -571,7 +571,7 b' class ifiledata(interfaceutil.Interface)'
571 571 def checkhash(fulltext, node, p1=None, p2=None, rev=None):
572 572 """Validate the stored hash of a given fulltext and node.
573 573
574 Raises ``error.RevlogError`` is hash validation fails.
574 Raises ``error.StorageError`` is hash validation fails.
575 575 """
576 576
577 577 def revision(node, raw=False):
@@ -422,7 +422,7 b' class ifiledatatests(basetestcase):'
422 422 with self.assertRaises(IndexError):
423 423 f.size(i)
424 424
425 with self.assertRaises(error.RevlogError):
425 with self.assertRaises(error.StorageError):
426 426 f.checkhash(b'', nullid)
427 427
428 428 with self.assertRaises(error.LookupError):
@@ -527,13 +527,13 b' class ifiledatatests(basetestcase):'
527 527 f.checkhash(fulltext, node)
528 528 f.checkhash(fulltext, node, nullid, nullid)
529 529
530 with self.assertRaises(error.RevlogError):
530 with self.assertRaises(error.StorageError):
531 531 f.checkhash(fulltext + b'extra', node)
532 532
533 with self.assertRaises(error.RevlogError):
533 with self.assertRaises(error.StorageError):
534 534 f.checkhash(fulltext, node, b'\x01' * 20, nullid)
535 535
536 with self.assertRaises(error.RevlogError):
536 with self.assertRaises(error.StorageError):
537 537 f.checkhash(fulltext, node, nullid, b'\x01' * 20)
538 538
539 539 self.assertEqual(f.revision(node), fulltext)
@@ -603,13 +603,13 b' class ifiledatatests(basetestcase):'
603 603 f.checkhash(fulltext1, node1, node0, nullid)
604 604 f.checkhash(fulltext2, node2, node1, nullid)
605 605
606 with self.assertRaises(error.RevlogError):
606 with self.assertRaises(error.StorageError):
607 607 f.checkhash(fulltext1, b'\x01' * 20)
608 608
609 with self.assertRaises(error.RevlogError):
609 with self.assertRaises(error.StorageError):
610 610 f.checkhash(fulltext1 + b'extra', node1, node0, nullid)
611 611
612 with self.assertRaises(error.RevlogError):
612 with self.assertRaises(error.StorageError):
613 613 f.checkhash(fulltext1, node1, node0, node0)
614 614
615 615 self.assertEqual(f.revision(node0), fulltext0)
@@ -852,7 +852,7 b' class ifilemutationtests(basetestcase):'
852 852 f = self._makefilefn()
853 853 with self._maketransactionfn() as tr:
854 854 # Adding a revision with bad node value fails.
855 with self.assertRaises(error.RevlogError):
855 with self.assertRaises(error.StorageError):
856 856 f.addrevision(b'foo', tr, 0, nullid, nullid, node=b'\x01' * 20)
857 857
858 858 def testaddrevisionunknownflag(self):
@@ -863,7 +863,7 b' class ifilemutationtests(basetestcase):'
863 863 flags = 1 << i
864 864 break
865 865
866 with self.assertRaises(error.RevlogError):
866 with self.assertRaises(error.StorageError):
867 867 f.addrevision(b'foo', tr, 0, nullid, nullid, flags=flags)
868 868
869 869 def testaddgroupsimple(self):
@@ -891,7 +891,7 b' class ifilemutationtests(basetestcase):'
891 891 ]
892 892
893 893 with self._maketransactionfn() as tr:
894 with self.assertRaises(error.RevlogError):
894 with self.assertRaises(error.StorageError):
895 895 f.addgroup(deltas, linkmapper, tr, addrevisioncb=cb)
896 896
897 897 node0 = f.add(fulltext0, None, tr, 0, nullid, nullid)
General Comments 0
You need to be logged in to leave comments. Login now