Skip to content

Commit 2177659

Browse files
author
Fredrik Gustafsson
committed
Extended the APIException by ErrorContent from response body
1 parent 41e4fc7 commit 2177659

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

modules/swagger-codegen/src/main/resources/csharp/api.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace {{package}} {
8383
// make the HTTP request
8484
IRestResponse response = restClient.Execute(_request);
8585
if (((int)response.StatusCode) >= 400) {
86-
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content);
86+
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
8787
}
8888
{{#returnType}}return ({{{returnType}}}) ApiInvoker.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
8989
return;{{/returnType}}
@@ -125,7 +125,7 @@ namespace {{package}} {
125125
// make the HTTP request
126126
IRestResponse response = await restClient.ExecuteTaskAsync(_request);
127127
if (((int)response.StatusCode) >= 400) {
128-
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content);
128+
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
129129
}
130130
{{#returnType}}return ({{{returnType}}}) ApiInvoker.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
131131
return;{{/returnType}}

modules/swagger-codegen/src/main/resources/csharp/apiException.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ namespace {{invokerPackage}} {
66
77
public int ErrorCode { get; set; }
88

9+
public dynamic ErrorContent { get; private set; }
10+
911
public ApiException() {}
1012

1113
public ApiException(int errorCode, string message) : base(message) {
1214
this.ErrorCode = errorCode;
1315
}
1416

17+
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) {
18+
this.errorCode = errorCode;
19+
this.errorContent = errorContent;
20+
}
21+
1522
}
1623

1724
}

0 commit comments

Comments
 (0)