def __init__(self, text=None, exc_cause=None): if not text and exc_cause: text = six.text_type(exc_cause) if exc_cause and six.PY2: # -- NOTE: Python2 does not show chained-exception causes. # Therefore, provide some hint (see also: PEP-3134). cause_text = ExceptionUtil.describe(exc_cause, use_traceback=True, prefix="CAUSED-BY: ") text += "\n" + cause_text ValueError.__init__(self, text) if exc_cause: # -- CHAINED EXCEPTION (see: PEP 3134) ChainedExceptionUtil.set_cause(self, exc_cause)
def __init__(self, text=None, exc_cause=None): if not text and exc_cause: text = six.text_type(exc_cause) if exc_cause and six.PY2: # -- NOTE: Python2 does not show chained-exception causes. # Therefore, provide some hint (see also: PEP-3134). cause_text = ExceptionUtil.describe(exc_cause, use_traceback=True, prefix="CAUSED-BY: ") text += u"\n" + cause_text ValueError.__init__(self, text) if exc_cause: # -- CHAINED EXCEPTION (see: PEP 3134) ChainedExceptionUtil.set_cause(self, exc_cause)