Skip to content

Commit 482bd16

Browse files
committed
🐛 remove gui error reporting, fixing #9
It would display the error message even if it was caught. Investigated using sys.excepthook, but it wouldn't work inside the function for some reason.
1 parent bd50583 commit 482bd16

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

pynode_next/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import webbrowser
2-
32
from .misc import *
43
from .node import *
54
from .errors import *
@@ -12,4 +11,3 @@ def begin_pynode_next(func, open_browser=True):
1211
webbrowser.open(f"http://localhost:{core.port}")
1312

1413
core.run(func)
15-

pynode_next/errors.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import sys
12
from .core import core
23

3-
class Error(Exception):
4+
class Error(RuntimeError):
45
"""The base error exception."""
56
def __init__(self, message):
67
# self.canvas.dispatch(dispatch_dict)
7-
core.ax(lambda x: x.dispatch({"isPyNodeNext": True, "type": "error", "message": message}))
8+
super().__init__(message)
9+
self.message = message
10+
# core.ax(lambda x: x.dispatch({"isPyNodeNext": True, "type": "error", "message": self.message}))
811

912
class DuplicateNodeError(Error):
1013
"""Raised when a node with the same id as a previous one was added."""

test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import inspect
2-
from typing import Iterable, List, Union, get_args
2+
from sys import excepthook
3+
from types import DynamicClassAttribute
4+
from typing import Iterable, List, Union, final, get_args
35
from pynode_next import *
46
import random
57

8+
69
def test():
10+
raise Error('hello')
711
graph.add_node("a")
812
graph.add_node("b")
913
pause(500)
1014
graph.add_edge("a", "b")
1115
register_click_handler(lambda x: x.set_color(Color.GREEN))
1216

13-
1417
begin_pynode_next(test)

0 commit comments

Comments
 (0)