def METHOD_NAME(exctype, exc, tb):
    try:
        from edb.common import markup
        markup.dump(exc, file=sys.stderr)
        if _is_internal_error(exc):
            print(
                f'This is most likely a bug in EdgeDB. '
                f'Please consider opening an issue ticket '
                f'at https://github.com/edgedb/edgedb/issues/new'
                f'?template=bug_report.md'
            )
    except Exception as ex:
        print('!!! exception in edb.excepthook !!!', file=sys.stderr)
        # Attach the original exception as a context to top of the new chain,
        # but only if it's not already there.  Take some care to avoid looping
        # forever.
        visited = set()
        parent = ex
        while parent.__cause__ or (
                not parent.__suppress_context__ and parent.__context__):
            if (parent in visited or parent.__context__ is exc or
                    parent.__cause__ is exc):
                break
            visited.add(parent)
            parent = parent.__cause__ or parent.__context__
        parent.__context__ = exc
        parent.__cause__ = None
        _old_excepthook(type(ex), ex, ex.__traceback__)