catching grpc error on setup, displaying error dialog and exiting app

This commit is contained in:
Blake Harnden 2019-12-09 16:23:09 -08:00
parent c36a72bc16
commit 088a69d9d9
2 changed files with 32 additions and 19 deletions

View file

@ -98,6 +98,9 @@ class Application(tk.Frame):
def save_config(self):
appconfig.save(self.guiconfig)
def close(self):
self.master.destroy()
if __name__ == "__main__":
log_format = "%(asctime)s - %(levelname)s - %(module)s:%(funcName)s - %(message)s"

View file

@ -6,6 +6,9 @@ import logging
import os
import time
from pathlib import Path
from tkinter import messagebox
import grpc
from core.api.grpc import client, core_pb2
from coretk import appconfig
@ -386,6 +389,7 @@ class CoreClient:
:return: existing sessions
"""
try:
self.client.connect()
# get service information
@ -408,6 +412,12 @@ class CoreClient:
self.default_services = {
x.node_type: set(x.services) for x in response.defaults
}
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.UNAVAILABLE:
messagebox.showerror("Server Error", e.details())
else:
messagebox.showerror("GRPC Error", e.details())
self.app.close()
def get_session_state(self):
response = self.client.get_session(self.session_id)