private bool TryDeserializeError(string responseContent, out AdvertisementErrorResponse error) { try { error = JsonConvert.DeserializeObject <AdvertisementErrorResponse>(responseContent); } catch { error = null; } return(error != null); }
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]; }
public UnauthorizedException(string requestId, int httpStatusCode, AdvertisementErrorResponse errorResponse) : base(requestId, httpStatusCode, errorResponse?.Message) { this.Errors = errorResponse?.Errors ?? new AdvertisementError[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]; }