error handling. add: dialog
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from typing import Literal, Optional, Union
|
||||
from typing import Literal
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
from clan_cli.errors import ClanError
|
||||
from gi.repository import Gtk
|
||||
|
||||
Severity = Union[Literal["Error"], Literal["Warning"], Literal["Info"], str]
|
||||
Severity = Literal["Error"] | Literal["Warning"] | Literal["Info"] | str
|
||||
|
||||
def show_error_dialog(error: ClanError, severity: Optional[Severity] = "Error") -> None:
|
||||
|
||||
def show_error_dialog(error: ClanError, severity: Severity | None = "Error") -> None:
|
||||
message = str(error)
|
||||
dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, severity)
|
||||
dialog = Gtk.MessageDialog(
|
||||
None, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, severity
|
||||
)
|
||||
print("error:", message)
|
||||
dialog.format_secondary_text(message)
|
||||
dialog.run()
|
||||
|
||||
@@ -5,6 +5,7 @@ from gi.repository import GdkPixbuf, Gtk
|
||||
from ..interfaces import Callbacks
|
||||
from ..models import VMBase
|
||||
|
||||
|
||||
class ClanEditForm(Gtk.ListBox):
|
||||
def __init__(self, *, selected: VMBase | None) -> None:
|
||||
super().__init__()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
from clan_cli.errors import ClanError
|
||||
|
||||
import gi
|
||||
from clan_cli.clan_uri import ClanURI
|
||||
from clan_cli.errors import ClanError
|
||||
from clan_cli.history.add import add_history, list_history
|
||||
|
||||
from clan_vm_manager import assets
|
||||
@@ -80,7 +80,9 @@ class Trust(Gtk.Box):
|
||||
print(f"trusted: {uri}")
|
||||
add_history(uri)
|
||||
history = list_history()
|
||||
found = filter(lambda item: item.flake.flake_url == uri.get_internal(), history)
|
||||
found = filter(
|
||||
lambda item: item.flake.flake_url == uri.get_internal(), history
|
||||
)
|
||||
if found:
|
||||
[item] = found
|
||||
self.stack.add_titled(
|
||||
@@ -95,7 +97,6 @@ class Trust(Gtk.Box):
|
||||
show_error_dialog(e)
|
||||
|
||||
|
||||
|
||||
class Details(Gtk.Box):
|
||||
def __init__(self, url: str, description: str | None) -> None:
|
||||
super().__init__()
|
||||
|
||||
Reference in New Issue
Block a user