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