From acdccc428c3f8db146f6b2d4de374195ef0a2823 Mon Sep 17 00:00:00 2001 From: louisnw Date: Mon, 6 May 2024 11:47:19 +0100 Subject: [PATCH] catch JavaScriptException (and ignore if pywebview version < 5) --- lightweight_charts/chart.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lightweight_charts/chart.py b/lightweight_charts/chart.py index 19eb805..855ada2 100644 --- a/lightweight_charts/chart.py +++ b/lightweight_charts/chart.py @@ -2,6 +2,12 @@ import asyncio import multiprocessing as mp import webview +# temporary until we fix to pywebview v5 +try: + from webview.errors import JavascriptException +except ModuleNotFoundError: + JavascriptException = Exception + from lightweight_charts import abstract from .util import parse_event_message, FLOAT @@ -61,8 +67,12 @@ class PyWV: self.return_queue.put(self.windows[i].evaluate_js(arg[14:])) else: self.windows[i].evaluate_js(arg) - except KeyError: + except KeyError as e: return + except JavascriptException as e: + pass + # msg = eval(str(e)) + # raise JavascriptException(f"\n\nscript -> '{arg}',\nerror -> {msg['name']}[{msg['line']}:{msg['column']}]\n{msg['message']}") class Chart(abstract.AbstractChart):