def display_exceptions()

in src/graph_notebook/decorators/decorators.py [0:0]


def display_exceptions(func):
    @functools.wraps(func)
    def do_display_exceptions(*args, **kwargs):
        try:
            show_traceback = kwargs['local_ns']['graph_notebook_show_traceback']
        except KeyError:
            show_traceback = False
        clear_output()
        tab = widgets.Tab()

        server_error = False
        try:
            return func(*args, **kwargs)
        except KeyboardInterrupt:
            print('Keyboard interrupt detected.')
            return  # we must return since we have halted the kernel interrupt here. Otherwise the interrupt will not work.
        except HTTPError as http_ex:
            caught_ex = http_ex
            raw_html = http_ex_to_html(http_ex)
            server_error = True
        except GremlinServerError as gremlin_ex:
            caught_ex = gremlin_ex
            raw_html = gremlin_server_error_to_html(gremlin_ex)
            server_error = True
        except Exception as e:
            if show_traceback:
                caught_ex = traceback.format_exception(e)
                traceback.print_exception(e)
            else:
                caught_ex = e
                raw_html = exception_to_html(e)

        if 'local_ns' in kwargs:
            kwargs['local_ns']['graph_notebook_error'] = caught_ex

        if server_error or not show_traceback:
            html = HTML(raw_html)
            html_output = widgets.Output(layout={'overflow': 'scroll'})
            with html_output:
                display(html)
            tab.children = [html_output]
            tab.set_title(0, 'Error')
            display(tab)

    return do_display_exceptions