# GraphQL - Error handling

### Error handling status codes: Rest APIs vs GraphQL

[HTTP response status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) represent the nature of the response when there is an API call to the server. These status codes are unique for the type of response the server sends.&#x20;

For instance, if there is a successful API response, 200 OK is its status code. Errors codes like 400 for Bad Request, 404 for Not Found, 500 for Internal Server Error, 502 for Bad Gateway, and so on are common responses denoting a semantic meaning for end users.&#x20;

**REST APIs** use these exact codes to handle responses. So, if a server sends a Not Found response, REST APIs will send a 404 code.&#x20;

However, with **GraphQL**, the server responds only with the status code 200, even if the response body contains an error. And this can be a source of confusion.&#x20;

You get a response with status code 200 OK (success code) in GraphQL, but there’s a 400 Bad Request error. You have to manually pinpoint the issue by searching through the exact response body, rather than relying on the status code sent by GraphQL.

### How BetterBugs handles GraphQL errors?

**BetterBugs** parses through the erroneous response body while auto-attaching them to your bug report. That way, you know the exact semantic meaning of the server response whenever a server uses GraphQL.

For instance, if your application uses GraphQL and your server response has an error, you will still get a 200 OK status code for every API call. BetterBugs derives the exact status code with code logic and only then shows the error code to attach to your bug report.&#x20;

When you capture issues with BetterBugs, you clearly see the error in your bug report with the exact response code, like 400 series, 500 series, et,c rather than 200 OK every time you have an error in the server response.&#x20;

And that’s how BetterBugs excels in handling and capturing GraphQL errors.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.betterbugs.io/product-features/developer-tools/graphql-error-handling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
