Partially configured object: shows what is missing instead of cryptic error only
This commit is contained in:
@ -77,7 +77,6 @@ except:
|
||||
|
||||
PartiallyConfigured = functools.partial
|
||||
else:
|
||||
|
||||
class PartiallyConfigured(_functools.partial):
|
||||
@property # TODO XXX cache this
|
||||
def _options_values(self):
|
||||
|
||||
@ -3,10 +3,9 @@ import sys
|
||||
from contextlib import contextmanager
|
||||
from logging import ERROR
|
||||
|
||||
from mondrian import term
|
||||
|
||||
from bonobo.util import deprecated
|
||||
from bonobo.util.objects import Wrapper, get_name
|
||||
from mondrian import term
|
||||
|
||||
|
||||
@contextmanager
|
||||
@ -23,7 +22,7 @@ def unrecoverable(error_handler):
|
||||
yield
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
error_handler(*sys.exc_info(), level=ERROR)
|
||||
raise # raise unrecoverableerror from x ?
|
||||
raise # raise unrecoverableerror from exc ?
|
||||
|
||||
|
||||
class Lifecycle:
|
||||
@ -60,7 +59,10 @@ class Lifecycle:
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
"""One character status for this node. """
|
||||
"""
|
||||
One character status for this node.
|
||||
|
||||
"""
|
||||
if self._defunct:
|
||||
return '!'
|
||||
if not self.started:
|
||||
|
||||
@ -77,11 +77,18 @@ class NodeExecutionContext(BaseContext, WithStatistics):
|
||||
initial = self._get_initial_context()
|
||||
self._stack = ContextCurrifier(self.wrapped, *initial.args, **initial.kwargs)
|
||||
if isconfigurabletype(self.wrapped):
|
||||
# Not normal to have a partially configured object here, so let's warn the user instead of having get into
|
||||
# the hard trouble of understanding that by himself.
|
||||
raise TypeError(
|
||||
'Configurables should be instanciated before execution starts.\nGot {!r}.\n'.format(self.wrapped)
|
||||
)
|
||||
try:
|
||||
self.wrapped = self.wrapped(_final=True)
|
||||
except Exception as exc:
|
||||
# Not normal to have a partially configured object here, so let's warn the user instead of having get into
|
||||
# the hard trouble of understanding that by himself.
|
||||
raise TypeError(
|
||||
'Configurables should be instanciated before execution starts.\nGot {!r}.\n'.format(self.wrapped)
|
||||
) from exc
|
||||
else:
|
||||
raise TypeError(
|
||||
'Configurables should be instanciated before execution starts.\nGot {!r}.\n'.format(self.wrapped)
|
||||
)
|
||||
self._stack.setup(self)
|
||||
except Exception:
|
||||
# Set the logging level to the lowest possible, to avoid double log.
|
||||
|
||||
Reference in New Issue
Block a user