gaps: use ValueError for split

Callers may want to catch that.
This commit is contained in:
Dan Bungert 2022-06-14 10:51:51 -06:00
parent a93202e0a1
commit 11b77e8b2d
2 changed files with 2 additions and 2 deletions

View File

@ -47,7 +47,7 @@ class Gap:
the supplied size. If size is equal to the gap size, the second gap is the supplied size. If size is equal to the gap size, the second gap is
None. The original gap is unmodified.""" None. The original gap is unmodified."""
if size > self.size: if size > self.size:
raise Exception('requested size larger than gap') raise ValueError('requested size larger than gap')
if size == self.size: if size == self.size:
return (self, None) return (self, None)
first_gap = Gap(device=self.device, first_gap = Gap(device=self.device,

View File

@ -45,7 +45,7 @@ class TestSplitGap(unittest.TestCase):
def test_too_big(self): def test_too_big(self):
[gap] = gaps.parts_and_gaps(make_disk()) [gap] = gaps.parts_and_gaps(make_disk())
with self.assertRaises(Exception): with self.assertRaises(ValueError):
gap.split(gap.size + MiB) gap.split(gap.size + MiB)
def test_split(self): def test_split(self):