def send_error(errstring, rid=1, context=None, error_code=-311, details=None): """ sendError - return a json error result document remark: the 'context' is especially required to catch errors from the _before_ methods. The return of a _before_ must be of type response and must have the attribute response._exception set, to stop further processing, which otherwise will have ugly results!! :param errstring: An error message :type errstring: basestring :param rid: id value, for future versions :type rid: int :param context: default is None or 'before' :type context: string :param error_code: The error code in the JSON object along with the error message. :type error_code: int :param details: dict with additional details about the error (like challenges) :type details: dict :return: json rendered sting result :rtype: string """ if details: details["threadid"] = threading.current_thread().ident res = { "jsonrpc": "2.0", "detail": details, "result": { "status": False, "error": { "code": error_code, "message": errstring } }, "version": get_version(), "id": rid, "time": time.time() } ret = jsonify(res) return ret
def send_error(errstring, rid=1, context=None, error_code=-311, details=None): """ sendError - return a json error result document remark: the 'context' is especially required to catch errors from the _before_ methods. The return of a _before_ must be of type response and must have the attribute response._exception set, to stop further processing, which otherwise will have ugly results!! :param errstring: An error message :type errstring: basestring :param rid: id value, for future versions :type rid: int :param context: default is None or 'before' :type context: string :param error_code: The error code in the JSON object along with the error message. :type error_code: int :param details: dict with additional details about the error (like challenges) :type details: dict :return: json rendered sting result :rtype: string """ if details: details["threadid"] = threading.current_thread().ident res = {"jsonrpc": "2.0", "detail": details, "result": {"status": False, "error": {"code": error_code, "message": errstring} }, "version": get_version(), "id": rid, "time": time.time() } ret = jsonify(res) return ret