OpenAPITools / OpenAPITools/openapi-generator

[REQ] Typescript-fetch returns error message

Open
#17,988 13 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

I have use cases where I am needed to get a more specific error code than the basics HTTP codes.
For example : I have several cases when I can get a 403. End of subscription or banned.

Describe the solution you'd like

I want to get the API's message returning to my request and not only the HTTP code and "Response returned an error code" as actualy happening.

To resolve this issue I changed the code of the request method in the 'runtime.ts' file as followed :
const message: string = !response.ok ? (await response.json()).message : 'Response returned an error code'; throw new ResponseError(response, message);
Screenshot 2024-02-28 125137

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the TypeScript-fetch runtime.ts implementation and the existing ResponseError handling. Check how generated clients currently handle non-OK responses, then verify that the API-provided message is surfaced while existing HTTP-error behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.