get rid of ValueError

This commit is contained in:
Jörg Thalheim
2024-09-03 18:07:36 +02:00
parent 403b9cf2cc
commit f18771364c
11 changed files with 34 additions and 22 deletions

View File

@@ -5,6 +5,7 @@ from typing import Any, Generic, TypeVar
import gi
gi.require_version("Gio", "2.0")
from clan_cli.errors import ClanError
from gi.repository import Gio, GObject
log = logging.getLogger(__name__)
@@ -77,7 +78,7 @@ class GKVStore(GObject.GObject, Gio.ListModel, Generic[K, V]):
key = self.key_gen(item)
if key in self._items:
msg = "Key already exists in the dictionary"
raise ValueError(msg)
raise ClanError(msg)
if position < 0 or position > len(self._items):
msg = "Index out of range"
raise IndexError(msg)

View File

@@ -6,6 +6,7 @@ from typing import Any, TypeVar
import gi
from clan_cli.clan_uri import ClanURI
from clan_cli.errors import ClanError
from clan_vm_manager.components.gkvstore import GKVStore
from clan_vm_manager.components.interfaces import ClanConfig
@@ -259,7 +260,7 @@ class ClanList(Gtk.Box):
vm = ClanStore.use().set_logging_vm(target)
if vm is None:
msg = f"VM {target} not found"
raise ValueError(msg)
raise ClanError(msg)
views = ViewStack.use().view
# Reset the logs view
@@ -267,7 +268,7 @@ class ClanList(Gtk.Box):
if logs is None:
msg = "Logs view not found"
raise ValueError(msg)
raise ClanError(msg)
name = vm.machine.name if vm.machine else "Unknown"