Commit dc543c4
committed
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.1 parent 445830d commit dc543c4
1 file changed
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
112 | 134 | | |
113 | 135 | | |
114 | 136 | | |
115 | | - | |
116 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
117 | 143 | | |
118 | 144 | | |
119 | 145 | | |
| |||
0 commit comments