Fix exception messages not interpolated properly

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2021-12-14 18:36:55 +01:00
parent 784a46845f
commit 68b9c42fac
6 changed files with 7 additions and 7 deletions

View File

@ -164,7 +164,7 @@ class Serializer:
serializer = self.type_serializers[annotation]
except KeyError:
raise Exception(
"do not know how to handle %s at %s", annotation, path)
f"do not know how to handle {annotation} at {path}")
else:
return serializer(annotation, value, metadata, path)

View File

@ -1417,7 +1417,7 @@ class FilesystemModel(object):
volume.flag == 'bios_grub' and fstype == 'fat32')):
raise Exception("{} is not available".format(volume))
if volume._fs is not None:
raise Exception("%s is already formatted", volume)
raise Exception(f"{volume} is already formatted")
fs = Filesystem(
m=self, volume=volume, fstype=fstype, preserve=preserve)
self._actions.append(fs)
@ -1430,7 +1430,7 @@ class FilesystemModel(object):
def add_mount(self, fs, path):
if fs._mount is not None:
raise Exception("%s is already mounted", fs)
raise Exception(f"{fs} is already mounted")
m = Mount(m=self, device=fs, path=path)
self._actions.append(m)
return m

View File

@ -100,7 +100,7 @@ class RefreshController(SubiquityController):
while True:
change = await self.get_progress(change_id)
if change['status'] not in ['Do', 'Doing', 'Done']:
raise Exception("update failed: %s", change['status'])
raise Exception(f"update failed: {change['status']}")
await asyncio.sleep(0.1)
@with_context()

View File

@ -129,7 +129,7 @@ class MountSelector(WidgetWrap):
self._selector.value = OTHER
self._showhide_other(True)
if not val.startswith('/'):
raise ValueError("%s does not start with /", val)
raise ValueError(f"{val} does not start with /")
self._other.value = val[1:]

View File

@ -125,7 +125,7 @@ class Option:
self.enabled = True
self.value = val
else:
raise SelectorError("invalid option %r", val)
raise SelectorError(f"invalid option {val!r}")
elif len(val) == 1:
self.label = val[0]
self.enabled = True

View File

@ -57,4 +57,4 @@ def widget_width(w):
r += widget_width(w1)
r += (len(w.contents) - 1) * w.dividechars
return r
raise Exception("don't know how to find width of %r", w)
raise Exception(f"don't know how to find width of {w!r}")