C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
APIRequestException.cs
Go to the documentation of this file.
1using System;
2
4using RestSharp;
5
6namespace AnalyzeRe
7{
14 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage",
15 "CA2237:MarkISerializableTypesWithSerializable")]
16 public class APIRequestException : Exception
17 {
19 public IRestResponse RestResponse { get; set; }
20
23 public ServerError ServerError { get; set; }
24
27 public IRestRequest Request => RestResponse?.Request;
28
38 string message,
39 Exception innerException = null,
42 : base(message, innerException)
43 {
46 }
47
51 public override string ToString()
52 {
53 return "APIRequestException.RestResponse: " + (RestResponse == null ?
54 "(null)" : Indent("\n" + RestResponse.PrettyPrint())) +
55 "\nAPIRequestException.ServerError: " + (ServerError == null ?
56 "(null)" : Indent("\n" + ServerError)) +
57 "\nAPIRequestException.Base Exception:" + Indent("\n" + base.ToString());
58 }
59
60 // Used to build a pretty ToString from exception sub-properties.
61 private static string Indent(object toConvertToString)
62 {
63 return toConvertToString.ToString().Replace("\n", "\n ");
64 }
65 }
66}
A custom exception class that includes the RestSharp.IRestResponse that generated the exception,...
IRestRequest Request
The original request object (obtained via the IRestResponse.Request property)
IRestResponse RestResponse
The IRestResponse that generated this exception.
APIRequestException(string message, Exception innerException=null, IRestResponse restResponse=null, ServerError serverError=null)
Construct a new APIRequestException.
override string ToString()
Creates and returns a string representation of the current exception that includes a summary of the R...
Describes a collection of resources which can be listed.
Used to deserialize server error messages.
Definition ServerError.cs:9