错误处理类:LuyAException

当程序出错,或者是请求有异常的时候,开发者们可以通过LuyAException类来捕获想要的异常。

比如说,你想要重写404页面,你可以这么做

@app.exception(LuyAException('page not found', status_code=404))
async def helloWorld(request, exception):
    return response.text('page not found')

简单的使用LuyAException类定义一个status_code = 404错误代码,你就能轻松的捕获到任何404错误的请求.

results matching ""

    No results matching ""