From 9e61032c319cfcdd35703b70a9dc9fba74bbc330 Mon Sep 17 00:00:00 2001 From: Artem Veremey Date: Sat, 27 Mar 2021 10:09:45 -0700 Subject: [PATCH] Wrapping a plot call in a try block to gracefully handle an exception --- gamestonk_terminal/helper_funcs.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gamestonk_terminal/helper_funcs.py b/gamestonk_terminal/helper_funcs.py index 8676f149b46..11a3ffbe196 100644 --- a/gamestonk_terminal/helper_funcs.py +++ b/gamestonk_terminal/helper_funcs.py @@ -41,7 +41,16 @@ def valid_date(s: str) -> datetime: def plot_view_stock(df, symbol): df.sort_index(ascending=True, inplace=True) - _, axVolume = plt.subplots(figsize=plot_autoscale(), dpi=cfgPlot.PLOT_DPI) + + try: + _, axVolume = plt.subplots(figsize=plot_autoscale(), dpi=cfgPlot.PLOT_DPI) + except Exception as e: + print(e) + print( + "Encountered an error trying to open a chart window. Check your X server configuration." + ) + return + plt.bar(df.index, df.iloc[:, -1], color="k", alpha=0.8, width=0.3) plt.ylabel("Volume") _ = axVolume.twinx()