# -*- coding: utf-8 -*-
# Package placeholder

import traceback


def format_last_exception(prefix="  | "):
    """Format the last exception for display it in tests.

    This allows to raise custom exception, without loosing the context of what
    caused the problem in the first place:

    >>> def f():
    ...     raise Exception("Something terrible happened")
    >>> try:  ## doctest: +ELLIPSIS
    ...     f()
    ... except Exception:
    ...     formated_exception = format_last_exception()
    ...     raise ValueError('Oups, an error occured:\\n%s' % formated_exception)
    Traceback (most recent call last):
    ...
    ValueError: Oups, an error occured:
      | Traceback (most recent call last):
    ...
      | Exception: Something terrible happened

    """

    return '\n'.join(str(prefix + line) 
                     for line in traceback.format_exc().strip().split('\n'))


# -*- coding: utf-8 -*-
# Package placeholder

import traceback


def format_last_exception(prefix="  | "):
    """Format the last exception for display it in tests.

    This allows to raise custom exception, without loosing the context of what
    caused the problem in the first place:

    >>> def f():
    ...     raise Exception("Something terrible happened")
    >>> try:  ## doctest: +ELLIPSIS
    ...     f()
    ... except Exception:
    ...     formated_exception = format_last_exception()
    ...     raise ValueError('Oups, an error occured:\\n%s' % formated_exception)
    Traceback (most recent call last):
    ...
    ValueError: Oups, an error occured:
      | Traceback (most recent call last):
    ...
      | Exception: Something terrible happened

    """

    return '\n'.join(str(prefix + line) 
                     for line in traceback.format_exc().strip().split('\n'))


# -*- coding: utf-8 -*- # Package placeholder Format the last exception for display it in tests.      This allows to raise custom exception, without loosing the context of what     caused the problem in the first place:      >>> def f():     ...     raise Exception("Something terrible happened")     >>> try:  ## doctest: +ELLIPSIS     ...     f()     ... except Exception:     ...     formated_exception = format_last_exception()     ...     raise ValueError('Oups, an error occured:\\n%s' % formated_exception)     Traceback (most recent call last):     ...     ValueError: Oups, an error occured:       | Traceback (most recent call last):     ...       | Exception: Something terrible happened