When the response is not ok the fetcher tries to parse the response body as JSON:
|
try { |
|
error = await response.json(); |
|
} catch (e) { |
|
error = { |
|
status: "unknown" as const, |
|
payload: |
|
e instanceof Error |
|
? \`Unexpected error (\${e.message})\` |
|
: "Unexpected error" |
|
}; |
|
} |
However when the response body is not JSON or malformed, response.json() throws an "Unexpected end of JSON input" error and the original response error get's lost.
When the response is not
okthe fetcher tries to parse the response body as JSON:openapi-codegen/plugins/typescript/src/templates/fetcher.ts
Lines 103 to 113 in aac52ca
However when the response body is not JSON or malformed,
response.json()throws an "Unexpected end of JSON input" error and the original response error get's lost.