display error dialog when start session fails
This commit is contained in:
parent
ceb3d072da
commit
3a2da0282f
2 changed files with 24 additions and 0 deletions
|
@ -36,3 +36,12 @@ def show_grpc_error(e: "grpc.RpcError", master, app: "Application"):
|
||||||
title = f"GRPC {title}"
|
title = f"GRPC {title}"
|
||||||
dialog = ErrorDialog(master, app, title, e.details())
|
dialog = ErrorDialog(master, app, title, e.details())
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
|
|
||||||
|
def show_grpc_response_exceptions(class_name, exceptions, master, app: "Application"):
|
||||||
|
title = f"Exceptions from {class_name}"
|
||||||
|
detail = ""
|
||||||
|
for e in exceptions:
|
||||||
|
detail = detail + f"{e}\n"
|
||||||
|
dialog = ErrorDialog(master, app, title, detail)
|
||||||
|
dialog.show()
|
||||||
|
|
|
@ -2,6 +2,8 @@ import logging
|
||||||
import threading
|
import threading
|
||||||
from typing import Any, Callable
|
from typing import Any, Callable
|
||||||
|
|
||||||
|
from core.gui.errors import show_grpc_response_exceptions
|
||||||
|
|
||||||
|
|
||||||
class BackgroundTask:
|
class BackgroundTask:
|
||||||
def __init__(self, master: Any, task: Callable, callback: Callable = None, args=()):
|
def __init__(self, master: Any, task: Callable, callback: Callable = None, args=()):
|
||||||
|
@ -19,6 +21,19 @@ class BackgroundTask:
|
||||||
def run(self):
|
def run(self):
|
||||||
result = self.task(*self.args)
|
result = self.task(*self.args)
|
||||||
logging.info("task completed")
|
logging.info("task completed")
|
||||||
|
# if start session fails, a response with Result: False and a list of exceptions is returned
|
||||||
|
if hasattr(result, "result") and not result.result:
|
||||||
|
if hasattr(result, "exceptions") and len(result.exceptions) > 0:
|
||||||
|
self.master.after(
|
||||||
|
0,
|
||||||
|
show_grpc_response_exceptions,
|
||||||
|
*(
|
||||||
|
result.__class__.__name__,
|
||||||
|
result.exceptions,
|
||||||
|
self.master,
|
||||||
|
self.master,
|
||||||
|
)
|
||||||
|
)
|
||||||
if self.callback:
|
if self.callback:
|
||||||
if result is None:
|
if result is None:
|
||||||
args = ()
|
args = ()
|
||||||
|
|
Loading…
Add table
Reference in a new issue