Hi there,

What is the best way to manage certain type of exceptions so that they
don't produce a '500 Internal Error' HTTP status?

First I thought about request decorators but then I realized that
decorating *each* request seem to be a bit overkill.  Then I thought
about application decorators:  the documentation even contains an
example where a try-except block is put within an handler.  So I come
up with the following handler:

def manage_content_exceptions(handler):
    web.ctx.logger.info("before_manage")
    try:
        return handler()
    except app.exceptions.ResponseContent as r:
        return r.content
    finally:
        web.ctx.logger.info("after_manage")

What happens here is that the finally block is never executed and
consequently the exception is caught by the application and an
internal error is sent back to the client.

Could you please shed some light on the subject and tell me what's
wrong with my handler?  I even found another discussion [1] about same
issue but unfortunately it is unanswered.


Regards,

Matteo

[1] https://groups.google.com/d/msg/webpy/f7IBxCgvIoY/GQxeHKVw8pcJ

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to webpy+unsubscr...@googlegroups.com.
To post to this group, send email to webpy@googlegroups.com.
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to