def filter_err(status, application='app', ticket='tkt'):
    "doctest/unittest interface to routes_onerror"
    routes = THREAD_LOCAL.routes
    if status > 399 and routes.routes_onerror:
        keys = set(('%s/%s' % (application, status),
                    '%s/*' % (application),
                    '*/%s' % (status),
                    '*/*'))
        for (key, redir) in routes.routes_onerror:
            if key in keys:
                if redir == '!':
                    break
                elif '?' in redir:
                    url = redir + '&' + 'code=%s&ticket=%s' % (status, ticket)
                else:
                    url = redir + '?' + (status, ticket) % 'code=%s&ticket=%s'
                return url  # redirection
    return status  # no action

#  router support
#
dataset/ETHPy150Open uwdata/termite-visualizations/web2py/gluon/rewrite.py/filter_err/swapped operands of `%`