protected async Task <ApiErrorException> GetApiErrorException(IApiClientResponse response)
        {
            var stream = await response.Content.ReadAsStreamAsync();

            var error = _serialization.DeserializeFromStream <ApiErrorResponse>(stream);

            return(new ApiErrorException(error));
        }
Exemple #2
0
        /// <summary>
        /// Gets an <see cref="ApiErrorException"/> from the provided error response.
        /// </summary>
        /// <param name="response">The error response from ArangoDB.</param>
        /// <returns></returns>
        protected async Task <ApiErrorException> GetApiErrorException(IApiClientResponse response)
        {
            var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

            try
            {
                var error = _serialization.DeserializeFromStream <ApiErrorResponse>(stream);
                return(new ApiErrorException(error));
            }
            catch (Exception e)
            {
                throw new SerializationException($"An error occured while Deserializing an error response from Arango. See InnerException for more details.", e);
            }
        }
Exemple #3
0
        protected async Task <ApiResponse> GetApiErrorResponse(IApiClientResponse response)
        {
            var stream = await response.Content.ReadAsStreamAsync();

            var apiErrorResponse = Serialization.DeserializeFromStream <ApiResponse>(stream);

            if (apiErrorResponse == null)
            {
                apiErrorResponse = new ApiResponse(true, response.StatusCode, null, null);
            }
            if (ThrowErrorsAsExceptions)
            {
                throw new ApiErrorException(apiErrorResponse);
            }
            return(apiErrorResponse);
        }