Example #1
0
        protected static void makeGenericErrorReponse(Common.JsonValue resp, string what, int errorCode = -32001)
        {
            JsonValue error = new JsonValue(JsonValue.OBJECT);

            JsonValue code = new JsonValue();

            code = (long)errorCode;

            string msg;

            if (what != null)
            {
                msg = what;
            }
            else
            {
                msg = "Unknown application error";
            }

            JsonValue message = new JsonValue();

            message = msg;

            error.insert("code", code);
            error.insert("message", message);

            resp.insert.functorMethod("error", error);
        }
Example #2
0
        protected static void makeInvalidPasswordResponse(Common.JsonValue resp)
        {
            JsonValue error = new JsonValue(JsonValue.OBJECT);

            JsonValue code = new JsonValue();

            code = (long)CryptoNote.JsonRpc.errInvalidPassword;

            JsonValue message = new JsonValue();

            message = "Invalid or no rpc password";

            error.insert("code", code);
            error.insert("message", message);

            resp.insert.functorMethod("error", error);
        }
Example #3
0
        protected static void makeMethodNotFoundResponse(Common.JsonValue resp)
        {
            JsonValue error = new JsonValue(JsonValue.OBJECT);

            JsonValue code = new JsonValue();

            code = (long)CryptoNote.JsonRpc.errMethodNotFound; //ambigous declaration of JsonValue::operator= (between int and JsonValue)

            JsonValue message = new JsonValue();

            message = "Method not found";

            error.insert("code", code);
            error.insert("message", message);

            resp.insert.functorMethod("error", error);
        }
Example #4
0
        protected static void makeJsonParsingErrorResponse(ref Common.JsonValue resp)
        {
            resp = new JsonValue(JsonValue.OBJECT);
            resp.insert.functorMethod("jsonrpc", "2.0");
            resp.insert.functorMethod("id", null);

            JsonValue error = new JsonValue(JsonValue.OBJECT);
            JsonValue code  = new JsonValue();

            code = (long)CryptoNote.JsonRpc.errParseError; //ambigous declaration of JsonValue::operator= (between int and JsonValue)

            JsonValue message = "Parse error";

            error.insert("code", code);
            error.insert("message", message);

            resp.insert.functorMethod("error", error);
        }
Example #5
0
        protected static void makeErrorResponse(std::error_code ec, Common.JsonValue resp)
        {
            JsonValue error = new JsonValue(JsonValue.OBJECT);

            JsonValue code = new JsonValue();

            code = (long)CryptoNote.JsonRpc.errParseError; //Application specific error code

            JsonValue message = new JsonValue();

            message = ec.message();

            JsonValue data    = new JsonValue(JsonValue.OBJECT);
            JsonValue appCode = new JsonValue();

            appCode = (long)ec.value();
            data.insert("application_code", appCode);

            error.insert("code", code);
            error.insert("message", message);
            error.insert("data", data);

            resp.insert.functorMethod("error", error);
        }
        public override bool BeginObject(Common.StringView name)
        {
            JsonValue parent = chain[chain.Count - 1].functorMethod;
            JsonValue obj    = new JsonValue(JsonValue.OBJECT);

            if (parent.isObject())
            {
                chain.Add(parent.insert((string)name, obj));
            }
            else
            {
                chain.Add(parent.pushBack(obj));
            }

            return(true);
        }