# errors

All exceptions/errors thrown from the maci library, including 3rd-party libraries, are redirected and handled with a maci-specific naming convention and helpful output.

The helpful output aims to try and provide useful and easy-to-understand information to quickly gather the reason for the exception thrown. This helpful output effort will consistently be improved or reiterated, and therefore an example will not be given.

### path name convention

The exception path name convention contains 3-parts and ensures simplicity in locating the exception.\
\
Here is the convention and how to break it down:

*Example exception name:*  maci.error.ExceptionName

* `maci` is the top-level module name.
* `error` is a submodule of `maci`, which contains definitions of various error or exception classes related to the `maci` module.
* `ExceptionName` is the class name of the specific exception being raised.

### handling exception thrown

Any time an exception is thrown, maci will provide the true module path followed by the class name of the exception to keep it simple, so there is no need to import anything additional to handle it.\
\
\&#xNAN;*Example of maci exception thrown by* [*load*](/docs/maci/functions/maci.load.md) *showing the full module and class path for bad filepath*

```bash
maci.error.Load: [Errno 2] No such file or directory: 'test.data'
```

If needing to handle this, you would simply write or copy the exception path, and that will handle that specific exception.

*Example handling above exception*

```python
try:
    ...
except maci.error.Load:
    ...
```

### maci base exception

All maci exceptions derive from its base exception **MaciError**. To handle all exceptions thrown from the maci library, you can handle the following exception path:

```python
maci.error.MaciError
```


---

# 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.macilib.org/docs/maci/errors.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.
