feat(csharp-netcore): Adding response headers to the ApiException (#7169)

This commit is contained in:
Sai Giridhar P
2020-08-09 21:40:57 +05:30
committed by GitHub
parent 5bbcf30c9c
commit 6f0bef61ba
6 changed files with 30 additions and 6 deletions

View File

@@ -21,6 +21,12 @@ namespace {{packageName}}.Client
/// <value>The error content (Http response body).</value>
public object ErrorContent { get; private set; }
/// <summary>
/// Gets or sets the HTTP headers
/// </summary>
/// <value>HTTP headers</value>
public Multimap<string, string> Headers { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
@@ -42,10 +48,12 @@ namespace {{packageName}}.Client
/// <param name="errorCode">HTTP status code.</param>
/// <param name="message">Error message.</param>
/// <param name="errorContent">Error content.</param>
public ApiException(int errorCode, string message, object errorContent = null) : base(message)
/// <param name="headers">HTTP Headers.</param>
public ApiException(int errorCode, string message, object errorContent = null, Multimap<string, string> headers = null) : base(message)
{
this.ErrorCode = errorCode;
this.ErrorContent = errorContent;
this.Headers = headers;
}
}

View File

@@ -47,7 +47,7 @@ namespace {{packageName}}.Client
{
return new ApiException(status,
string.Format("Error calling {0}: {1}", methodName, response.RawContent),
response.RawContent);
response.RawContent, response.Headers);
}
{{^netStandard}}if (status == 0)
{

View File

@@ -30,6 +30,12 @@ namespace Org.OpenAPITools.Client
/// <value>The error content (Http response body).</value>
public object ErrorContent { get; private set; }
/// <summary>
/// Gets or sets the HTTP headers
/// </summary>
/// <value>HTTP headers</value>
public Multimap<string, string> Headers { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
@@ -51,10 +57,12 @@ namespace Org.OpenAPITools.Client
/// <param name="errorCode">HTTP status code.</param>
/// <param name="message">Error message.</param>
/// <param name="errorContent">Error content.</param>
public ApiException(int errorCode, string message, object errorContent = null) : base(message)
/// <param name="headers">HTTP Headers.</param>
public ApiException(int errorCode, string message, object errorContent = null, Multimap<string, string> headers = null) : base(message)
{
this.ErrorCode = errorCode;
this.ErrorContent = errorContent;
this.Headers = headers;
}
}

View File

@@ -54,7 +54,7 @@ namespace Org.OpenAPITools.Client
{
return new ApiException(status,
string.Format("Error calling {0}: {1}", methodName, response.RawContent),
response.RawContent);
response.RawContent, response.Headers);
}
return null;

View File

@@ -30,6 +30,12 @@ namespace Org.OpenAPITools.Client
/// <value>The error content (Http response body).</value>
public object ErrorContent { get; private set; }
/// <summary>
/// Gets or sets the HTTP headers
/// </summary>
/// <value>HTTP headers</value>
public Multimap<string, string> Headers { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
@@ -51,10 +57,12 @@ namespace Org.OpenAPITools.Client
/// <param name="errorCode">HTTP status code.</param>
/// <param name="message">Error message.</param>
/// <param name="errorContent">Error content.</param>
public ApiException(int errorCode, string message, object errorContent = null) : base(message)
/// <param name="headers">HTTP Headers.</param>
public ApiException(int errorCode, string message, object errorContent = null, Multimap<string, string> headers = null) : base(message)
{
this.ErrorCode = errorCode;
this.ErrorContent = errorContent;
this.Headers = headers;
}
}

View File

@@ -54,7 +54,7 @@ namespace Org.OpenAPITools.Client
{
return new ApiException(status,
string.Format("Error calling {0}: {1}", methodName, response.RawContent),
response.RawContent);
response.RawContent, response.Headers);
}
if (status == 0)
{