openapi-typescript version
0.14.0
Node.js version
v22.20.0
OS + version
macOS 15.5
Description
I had to apply this patch to get proper error handling:
- const { data, error } = await this.client.POST(`/invitees`, {
+ const { data, error, response } = await this.client.POST(`/invitees`, {
body,
});
if (error) {
throw new ExInfo(`Error: ${error.message}`, {
data: { details: error.details },
cause: error,
});
}
+ if (!response.ok) {
+ throw new ExInfo(`Error: ${response.statusText}`, {
+ data: { details: response.statusText },
+ cause: response.statusText,
+ });
+ }
The reason is that error is sometimes undefined even though the server returned 4xx - specifically if the 4xx response is not mentioned in the openapi schema.
This happens with 429 Rate Limited errors which get added by Cloudflare (but not to the api spec).
Reproduction
Server response doesn't mention 429 error. Server returns 429 with no response body
Expected result
either
error is set to some value
- the docs state that you need to ALSO check response.ok
Required
Extra
openapi-typescript version
0.14.0
Node.js version
v22.20.0
OS + version
macOS 15.5
Description
I had to apply this patch to get proper error handling:
The reason is that
erroris sometimes undefined even though the server returned 4xx - specifically if the 4xx response is not mentioned in the openapi schema.This happens with 429 Rate Limited errors which get added by Cloudflare (but not to the api spec).
Reproduction
Server response doesn't mention 429 error. Server returns 429 with no response body
Expected result
either
erroris set to some valueRequired
npx @redocly/cli@latest lint)Extra