> For the complete documentation index, see [llms.txt](https://buycoins.youngest.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://buycoins.youngest.dev/exceptions.md).

# Exceptions

On the request level, the `HTTPError` exception when caught in the `except` block is raised by one of the built-in custom exception classes.

These built-in custom classes help the developer to understand the source of the error. The built-in custom classes are:

* ServerError
* AccountError
* ClientError
* WalletError
* QueryError
* P2PError

The custom classes are built with this template:

```python
class ClassError(Exception):
    def __init__(self, *args):
        if args:
            self.message = args[0]
            self.status_code = args[1]
        else:
            self.message = None
            self.status_code = 404

    @property
    def response(self):
        return {
            "status": "error",
            "name": "ClassError",
            "code": self.status_code,
            "message": self.message
        }
```

where `ClassError` is one of the available exception classes in the library.

### Example

To return the appropriate error response for an invalid query, the library executes this block of code:

```python
if not query or query == "":
    raise QueryError("Invalid query passed!", 400)

try:
    # some block of code
except QueryError as e: # Catch the earlier raised exception.
    return e.response # { status: "error", "name": "QueryError", "code": 400, message: "Invalid query passed" }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://buycoins.youngest.dev/exceptions.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.
