def render_error(exc, title, message, code, standalone=False):
    _save_error(exc, title, message)
    if _need_json_response():
        return _jsonify_error(exc, title, message, code)
    elif standalone:
        return (render_template('standalone_error.html', error_message=title, error_description=message), code)
    else:
        try:
            return (WPError(title, message).getHTML(), code)
        except OperationalError:
            return render_error(exc, title, message, code, standalone=True)
def render_error(exc, title, message, code, standalone=False):
    _save_error(exc, title, message)
    if _need_json_response():
        return _jsonify_error(exc, title, message, code)
    elif standalone:
        return (render_template('standalone_error.html', error_message=title, error_description=message), code)
    else:
        try:
            return (WPError(title, message).getHTML(), code)
        except OperationalError:
            return render_error(exc, title, message, code, standalone=True)