Beispiel #1
0
        internal static ErrorInfo Parse(AblyResponse response)
        {
            string reason    = "";
            int    errorCode = 500;

            if (response.Type == ResponseType.Json)
            {
                try
                {
                    var json = JObject.Parse(response.TextResponse);
                    if (json["error"] != null)
                    {
                        reason    = (string)json["error"]["message"];
                        errorCode = (int)json["error"]["code"];
                    }
                }
                catch (Exception ex)
                {
                    Debug.Write(ex.Message);
                    //If there is no json or there is something wrong we don't want to throw from here. The
                }
            }
            return(new ErrorInfo(reason.IsEmpty() ? "Unknown error" : reason, errorCode, response.StatusCode));
        }
Beispiel #2
0
 internal static AblyException FromResponse(AblyResponse response)
 {
     return(new AblyException(ErrorInfo.Parse(response)));
 }