mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
Extended the APIException by ErrorContent from response body
This commit is contained in:
parent
41e4fc79ae
commit
217765998d
@ -83,7 +83,7 @@ namespace {{package}} {
|
||||
// make the HTTP request
|
||||
IRestResponse response = restClient.Execute(_request);
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content);
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
||||
}
|
||||
{{#returnType}}return ({{{returnType}}}) ApiInvoker.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
|
||||
return;{{/returnType}}
|
||||
@ -125,7 +125,7 @@ namespace {{package}} {
|
||||
// make the HTTP request
|
||||
IRestResponse response = await restClient.ExecuteTaskAsync(_request);
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content);
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
||||
}
|
||||
{{#returnType}}return ({{{returnType}}}) ApiInvoker.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
|
||||
return;{{/returnType}}
|
||||
|
@ -6,12 +6,19 @@ namespace {{invokerPackage}} {
|
||||
|
||||
public int ErrorCode { get; set; }
|
||||
|
||||
public dynamic ErrorContent { get; private set; }
|
||||
|
||||
public ApiException() {}
|
||||
|
||||
public ApiException(int errorCode, string message) : base(message) {
|
||||
this.ErrorCode = errorCode;
|
||||
}
|
||||
|
||||
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) {
|
||||
this.errorCode = errorCode;
|
||||
this.errorContent = errorContent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user