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)); }
internal static AblyException FromResponse(AblyResponse response) { return(new AblyException(ErrorInfo.Parse(response))); }