private static IDictionary <string, string> CreateAdditionalInformation(ResponseError error)
 {
     if (string.IsNullOrEmpty(error.ToString()))
     {
         return(null);
     }
     return(new Dictionary <string, string>(1)
     {
         { "AdditionalInformation", error.ToString() }
     });
 }
        public static async ValueTask <RequestFailedException> CreateExceptionForFailedOperationAsync(bool async, ClientDiagnostics diagnostics, Response response, ResponseError error)
        {
            var additionalInfo = new Dictionary <string, string>(1)
            {
                { "AdditionInformation", error.ToString() }
            };

            return(async
                ? await diagnostics.CreateRequestFailedExceptionAsync(response, error.Message, error.Code, additionalInfo).ConfigureAwait(false)
                : diagnostics.CreateRequestFailedException(response, error.Message, error.Code, additionalInfo));
        }
Example #3
0
        /// <summary>
        /// GET
        /// </summary>
        public async Task <ResponseObject <TResPayload> > GetAsync <TResPayload>(
            string path,
            bool readPayload
            ) where TResPayload : Payload
        {
            // TODO: logging
            ResponseObject <TResPayload> data;
            var res = await _client.GetAsync(path).ConfigureAwait(false);

            if (res.IsSuccessStatusCode)
            {
                var resJson = await res.Content.ReadAsStringAsync();

                data = ResponseObject <TResPayload> .Build <TResPayload>(resJson, readPayload);
            }
            else
            {
                // TODO: correct error handling
                throw new Exception(ResponseError.ToString(path, null, res.ToString()));
            }
            return(data);
        }
Example #4
0
            public static string ToString(string method, string param, string error)
            {
                var err = new ResponseError(method, param, error);

                return(err.ToString());
            }