How to use the wasabi.TracebackPrinter function in wasabi

To help you get started, we’ve selected a few wasabi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github justindujardin / mathy / libraries / mathy_python / mathy / util.py View on Github external
def raise_with_history(
    title: str, description: str, history: Optional[List[Any]] = None,
):
    import traceback

    history_text: List[str] = []
    if history is not None:
        history_text = [f" - {h.raw}" for h in history]
    history_text.insert(0, description)
    tb = TracebackPrinter()
    error = tb(title, "\n".join(history_text), tb=traceback.extract_stack())
    raise ValueError(error)
github justindujardin / mathy / libraries / mathy_python / mathy / util.py View on Github external
def print_error(error, text, print_error=True):
    import traceback

    caught_error = TracebackPrinter(
        color_error="yellow", tb_base=".", tb_range_start=-15
    )(
        error.__class__.__name__,
        f"{error}",
        tb=traceback.extract_tb(error.__traceback__),
    )
    caught_at = TracebackPrinter(tb_base=".", tb_range_start=-15, tb_range_end=-1)(
        f"Error: {text}", f"Caught at:", tb=traceback.extract_stack(),
    )

    if print_error:
        print(caught_at + caught_error)
    else:
        raise ValueError(caught_at + caught_error)
github justindujardin / mathy / libraries / mathy_python / mathy / util.py View on Github external
def print_error(error, text, print_error=True):
    import traceback

    caught_error = TracebackPrinter(
        color_error="yellow", tb_base=".", tb_range_start=-15
    )(
        error.__class__.__name__,
        f"{error}",
        tb=traceback.extract_tb(error.__traceback__),
    )
    caught_at = TracebackPrinter(tb_base=".", tb_range_start=-15, tb_range_end=-1)(
        f"Error: {text}", f"Caught at:", tb=traceback.extract_stack(),
    )

    if print_error:
        print(caught_at + caught_error)
    else:
        raise ValueError(caught_at + caught_error)
github explosion / thinc / thinc / exceptions.py View on Github external
# coding: utf-8
from __future__ import unicode_literals

import traceback
from wasabi import TracebackPrinter, format_repr


get_error = TracebackPrinter(tb_base="thinc", tb_exclude=("check.py",))


class UndefinedOperatorError(TypeError):
    def __init__(self, op, arg1, arg2, operators):
        self.tb = traceback.extract_stack()
        TypeError.__init__(
            self,
            get_error(
                "Undefined operator: {op}".format(op=op),
                "Called by ({arg1}, {arg2})".format(arg1=arg1, arg2=arg2),
                "Available: {ops}".format(ops=", ".join(operators.keys())),
                tb=self.tb,
                highlight=op,
            ),
        )