浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Error Pages

If anything goes wrong Bottle displays an informative but fairly boring error page. You can override the default error pages using the error() decorator. It works similar to the route() decorator but expects an HTTP status code instead of a route:

<span class="nd">@error</span><span class="p">(</span><span class="mi">404</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">error404</span><span class="p">(</span><span class="n">error</span><span class="p">):</span>
    <span class="k">return</span> <span class="s">'Nothing here, sorry'</span>

The error parameter passed to the error handler is an instance of HTTPError.



posted on 2010-09-09 14:54  lexus  阅读(160)  评论(0编辑  收藏  举报