Commit 621a7a6
Consistently convert GraphQL errors to
In `GithubApi`, we have the helpful `EnsureSuccessGraphQLResponse`
helper which checks the GraphQL response for errors, and if an error is
found, it raises a `OctoshiftCliException`.
Currently, this helper is not used consistently across GraphQL API
calls, which means that we have some cases where the GraphQL API returns
an error and the CLI crashes with an unhelpful
`System.InvalidOperationException: Cannot access child value on
Newtonsoft.Json.Linq.JValue.`.
To find out what actually went wrong, the user has to either:
* (a) use the `--verbose` option or
* (b) manually check the verbose log file
This PR creates a new `PostGraphQLAsync` method on `GitHubClient` which
includes the error handling logic from `EnsureSuccessGraphQLResponse`.
We then use the `PostGraphQLAsync` method instead of `PostAsync` for
GraphQL requests, which means that we get this consistent error handling
for free.
I do not apply this to `ReclaimMannequin` (which has its own error
handling) and `GetMannequins` (which has some complex pagination logic
which I didn't want to mess with right now).
Fixes #867.
<!--
For the checkboxes below you must check each one to indicate that you
either did the relevant task, or considered it and decided there was
nothing that needed doing
-->
- [x] Did you write/update appropriate tests
- [x] Release notes updated (if appropriate)
- [x] Appropriate logging output
- [x] Issue linked
- [ ] Docs updated (or issue created)
- [ ] New package licenses are added to `ThirdPartyNotices.txt` (if
applicable)
<!--
For docs we should review the docs at:
https://docs.github.com/en/early-access/github/migrating-with-github-enterprise-importer
and the README.md in this repo
If a doc update is required based on the changes in this PR, it is
sufficient to create an issue and link to it here. The doc update can be
made later/separately.
The process to update the docs can be found here:
https://github.com/github/docs-early-access#opening-prs
The markdown files are here:
https://github.com/github/docs-early-access/tree/main/content/github/migrating-with-github-enterprise-importer
-->
---------
Co-authored-by: Arin Ghazarian <aringhazarian@github.com>OctoshiftCliExceptions with helpful error messages across GithubApi (#868)1 parent ae773bb commit 621a7a6
File tree
7 files changed
+280
-280
lines changed- src
- OctoshiftCLI.Tests
- Octoshift
- Octoshift
7 files changed
+280
-280
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 170 | + | |
174 | 171 | | |
175 | 172 | | |
176 | 173 | | |
| |||
192 | 189 | | |
193 | 190 | | |
194 | 191 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 192 | + | |
199 | 193 | | |
200 | 194 | | |
201 | 195 | | |
| |||
227 | 221 | | |
228 | 222 | | |
229 | 223 | | |
230 | | - | |
231 | | - | |
| 224 | + | |
232 | 225 | | |
233 | 226 | | |
234 | 227 | | |
| |||
253 | 246 | | |
254 | 247 | | |
255 | 248 | | |
256 | | - | |
257 | | - | |
| 249 | + | |
258 | 250 | | |
259 | 251 | | |
260 | 252 | | |
| |||
279 | 271 | | |
280 | 272 | | |
281 | 273 | | |
282 | | - | |
283 | | - | |
| 274 | + | |
284 | 275 | | |
285 | 276 | | |
286 | 277 | | |
| |||
351 | 342 | | |
352 | 343 | | |
353 | 344 | | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
| 345 | + | |
358 | 346 | | |
359 | 347 | | |
360 | 348 | | |
| |||
395 | 383 | | |
396 | 384 | | |
397 | 385 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
| 386 | + | |
402 | 387 | | |
403 | 388 | | |
404 | 389 | | |
| |||
414 | 399 | | |
415 | 400 | | |
416 | 401 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 402 | + | |
421 | 403 | | |
422 | 404 | | |
423 | 405 | | |
| |||
458 | 440 | | |
459 | 441 | | |
460 | 442 | | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
| 443 | + | |
465 | 444 | | |
466 | 445 | | |
467 | 446 | | |
| |||
494 | 473 | | |
495 | 474 | | |
496 | 475 | | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
| 476 | + | |
501 | 477 | | |
502 | 478 | | |
503 | 479 | | |
| |||
555 | 531 | | |
556 | 532 | | |
557 | 533 | | |
558 | | - | |
559 | | - | |
| 534 | + | |
560 | 535 | | |
561 | 536 | | |
562 | 537 | | |
| |||
582 | 557 | | |
583 | 558 | | |
584 | 559 | | |
585 | | - | |
586 | | - | |
| 560 | + | |
587 | 561 | | |
588 | 562 | | |
589 | 563 | | |
| |||
697 | 671 | | |
698 | 672 | | |
699 | 673 | | |
700 | | - | |
701 | | - | |
| 674 | + | |
702 | 675 | | |
703 | | - | |
| 676 | + | |
704 | 677 | | |
705 | 678 | | |
706 | 679 | | |
| |||
828 | 801 | | |
829 | 802 | | |
830 | 803 | | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | 804 | | |
842 | 805 | | |
843 | 806 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
76 | 88 | | |
77 | 89 | | |
78 | 90 | | |
| |||
237 | 249 | | |
238 | 250 | | |
239 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
240 | 262 | | |
241 | 263 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | 102 | | |
107 | 103 | | |
108 | 104 | | |
| |||
0 commit comments