Commit 668dbfd
committed
[csharp][restsharp] add throwOnAnyError option to surface client errors
By default, RestSharp swallows deserialization and transport
exceptions into RestResponse.ErrorException, and the generated
ToApiResponse<T> in this template only carries ErrorText — the
actual exception is dropped. Combined with a generated GetXxxAsync
that returns Data directly, callers silently receive null on any
deserialization failure (e.g. a required property missing in the
upstream JSON). The error never reaches application logs or APM.
Add an opt-in `throwOnAnyError` switch (default false, restsharp
library only) that sets `ThrowOnAnyError = true` on RestClientOptions,
making RestSharp rethrow the original ApiException(500, ...) that
the generated deserializer already throws. The exception then
propagates to the caller and into normal application error handling.
Default kept off to preserve backwards compatibility — opt in when
you want bugs to surface instead of silently producing null/[].1 parent 8a65919 commit 668dbfd
3 files changed
Lines changed: 14 additions & 1 deletion
File tree
- docs/generators
- modules/openapi-generator/src/main
- java/org/openapitools/codegen/languages
- resources/csharp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| 136 | + | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| |||
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| |||
871 | 877 | | |
872 | 878 | | |
873 | 879 | | |
| 880 | + | |
874 | 881 | | |
875 | 882 | | |
876 | 883 | | |
| |||
1244 | 1251 | | |
1245 | 1252 | | |
1246 | 1253 | | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
1247 | 1258 | | |
1248 | 1259 | | |
1249 | 1260 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | | - | |
| 470 | + | |
| 471 | + | |
471 | 472 | | |
472 | 473 | | |
473 | 474 | | |
| |||
0 commit comments