Beispiel #1
0
        private static HttpStatusCode GetHttpStatusCode(ApiResponse apiResponse)
        {
            if (apiResponse == null || apiResponse.status_code == null)
                return HttpStatusCode.InternalServerError;

            int intStatusCode;
            int.TryParse(apiResponse.status_code.Substring(2, 3), out intStatusCode);

            return (HttpStatusCode)(intStatusCode == 0 ? 500 : intStatusCode);
        }
Beispiel #2
0
        public ApiException(ApiResponse apiResponse)
            : base(String.Format("ApiException (HTTP {0}):\n{1}: {2} {3}", 
                                 (int)GetHttpStatusCode(apiResponse),
                                 apiResponse.status_code, 
                                 apiResponse.status_text, 
                                 String.IsNullOrEmpty(apiResponse.status_additional_data) ? "" : " - " + apiResponse.status_additional_data))
        {
            HttpStatusCode = GetHttpStatusCode(apiResponse);

            ApiResponse = apiResponse;
        }