コード例 #1
0
        private bool TryDeserializeError(string responseContent, out AdvertisementErrorResponse error)
        {
            try
            {
                error = JsonConvert.DeserializeObject <AdvertisementErrorResponse>(responseContent);
            }
            catch
            {
                error = null;
            }

            return(error != null);
        }
コード例 #2
0
 public ValidationException(string requestId, HttpMethod method, AdvertisementErrorResponse errorResponse)
     : base(requestId, 422, $"{method:G} failed.{errorResponse?.Message.PadLeft(errorResponse.Message.Length + 1)}")
 {
     this.Errors = errorResponse?.Errors ?? new AdvertisementError[0];
 }
コード例 #3
0
 public UnauthorizedException(string requestId, int httpStatusCode, AdvertisementErrorResponse errorResponse) : base(requestId, httpStatusCode, errorResponse?.Message)
 {
     this.Errors = errorResponse?.Errors ?? new AdvertisementError[0];
 }
コード例 #4
0
 public CreationIdAlreadyExistsException(string requestId, Uri advertisementLink, AdvertisementErrorResponse errorResponse)
     : base(requestId, (int)HttpStatusCode.Conflict, $"The {nameof(Advertisement.CreationId)} has already been used to create an advertisement. The {nameof(AdvertisementLink)} property provides the link to the conflicting advertisement.")
 {
     this.AdvertisementLink = advertisementLink;
     this.Errors            = errorResponse?.Errors ?? new Error[0];
 }