Configure application error handlers

def configure_error_handlers(app):
    """ Configure application error handlers """

    def render_error(error):
        return (render_template('errors/%s.html' % error.code,
                title=error_messages[error.code], code=error.code), error.code)

    for (errcode, title) in error_messages.iteritems():
        app.errorhandler(errcode)(render_error)