def METHOD_NAME(self, etype, value, tb, tb_offset=None):
    # when the 'tb_offset' keyword argument is omitted above, ipython
    # raises an error.
    TB = AutoFormattedTB(mode='Context', color_scheme='Linux', tb_offset=1)
    fc = qkit.flow
    # for the unlikely event that an error occured after pushing the
    # stop button
    fc._abort = False
    if fc.is_measuring():
        # put qtlab back in 'stopped' state
        fc.measurement_end(abort=True)
    TB(etype, value, tb)