Commit 4a31d13
authored
REF: DX-1182 Prevent TypeError when API returns error responses (#47)
* Prevent TypeError when API returns error responses
Improvements: DX-1182
Previously, when the API returned non-404 error responses (401, 500, etc.),
the code would attempt to call .map() on the error object, resulting in:
"TypeError: responseBody.map is not a function"
Changes:
- Add validation for HTTP status codes before processing response
- Check if responseBody is an array before calling .map()
- Extract and include error details from API error responses
- Provide clear, actionable error messages
Example error messages:
- "Failed to fetch revisions (HTTP 401): unauthorized"
- "Expected array of revisions, but got object: {...}"
This fix addresses transient API failures and authentication issues that
previously resulted in cryptic TypeErrors.
* Address issues pointed out by automated review.1 parent 7e7947d commit 4a31d13
1 file changed
Lines changed: 30 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
114 | | - | |
| 112 | + | |
115 | 113 | | |
116 | 114 | | |
117 | 115 | | |
118 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
119 | 146 | | |
120 | 147 | | |
121 | 148 | | |
| |||
0 commit comments