diff options
| author | tassaron | 2017-07-25 17:44:59 -0400 |
|---|---|---|
| committer | tassaron | 2017-07-25 17:44:59 -0400 |
| commit | 661526b0739115594fda4c0e876398cdc940fbe1 (patch) | |
| tree | c5bfdf136bd7f72abed54d3bb83d831bcfc43555 /src/component.py | |
| parent | d25dee6afc0cc72f477b577623079b4d644957a8 (diff) | |
repeated errors don't cause repeated windows
Diffstat (limited to 'src/component.py')
| -rw-r--r-- | src/component.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/component.py b/src/component.py index 48e9c1a..7a768ed 100644 --- a/src/component.py +++ b/src/component.py @@ -17,7 +17,7 @@ class ComponentMetaclass(type(QtCore.QObject)): def initializationWrapper(self, *args, **kwargs): try: return func(self, *args, **kwargs) - except: + except Exception: try: raise ComponentInitError(self, 'initialization process') except ComponentError: @@ -28,7 +28,7 @@ class ComponentMetaclass(type(QtCore.QObject)): def renderWrapper(self, *args, **kwargs): try: return func(self, *args, **kwargs) - except: + except Exception: from toolkit.frame import BlankFrame try: raise ComponentError(self, 'renderer') @@ -398,8 +398,19 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass): class ComponentException(RuntimeError): '''A base class for component errors''' + + _prevErrors = [] + def __init__(self, caller, name, immediate): + print('ComponentError by %s: %s' % (caller.name, name)) super().__init__() + if len(ComponentException._prevErrors) > 1: + ComponentException._prevErrors.pop() + ComponentException._prevErrors.insert(0, name) + if name in ComponentException._prevErrors[1:]: + # Don't create multiple windows for repeated messages + return + from toolkit import formatTraceback import sys if sys.exc_info()[0] is not None: |
