Ejemplo n.º 1
0
        public static XError FromJson(JObject error)
        {
            int code = Convert.ToInt32(error["code"].Value<JValue>().Value.ToString());
            string method = (string)error["data"]["method"];
            string rootMessage = (error["data"]["message"] != null) ? (string)error["data"]["message"] : "";
            string stackmessage = string.Empty;
            string stackitemname = string.Empty;
            string stackpropertymessage = string.Empty;

            if (error["data"]["stack"] != null)
            {
                stackmessage = (error["data"]["stack"]["message"] != null) ? (string)error["data"]["stack"]["message"] : "";
                stackitemname = (error["data"]["stack"]["name"] != null) ? (string)error["data"]["stack"]["name"] : "";
                //stackpropertymessage = (error["data"]["stack"]["property"]["message"] != null) ? (string)error["data"]["stack"]["property"]["message"] : "";
            }

            var errorObject = new XError(
                code,
                method,
                rootMessage,
                stackmessage,
                stackitemname,
                stackpropertymessage,
                error
            );

            return errorObject;
        }
Ejemplo n.º 2
0
 public static Boolean CheckResponseForError(JObject response, out XError error)
 {
     if (response["error"] != null)
     {
         error = XError.FromJson((JObject)response["error"]);
         return true;
     }
     error = null;
     return false;
 }