Trying to fix unending transformations on start() error.

This commit is contained in:
Romain Dorgueil
2017-05-01 15:12:48 +02:00
parent bd0b9a3098
commit 474999a87e
6 changed files with 90 additions and 64 deletions

30
bonobo/util/errors.py Normal file
View File

@ -0,0 +1,30 @@
import sys
from bonobo.structs.bags import ErrorBag
def is_error(bag):
return isinstance(bag, ErrorBag)
def print_error(exc, trace, context=None, prefix=''):
"""
Error handler. Whatever happens in a plugin or component, if it looks like an exception, taste like an exception
or somehow make me think it is an exception, I'll handle it.
:param exc: the culprit
:param trace: Hercule Poirot's logbook.
:return: to hell
"""
from colorama import Fore, Style
print(
Style.BRIGHT,
Fore.RED,
'\U0001F4A3 {}{}{}'.format((prefix + ': ') if prefix else '', type(exc).__name__,
' in {!r}'.format(context) if context else ''),
Style.RESET_ALL,
sep='',
file=sys.stderr,
)
print(trace)