# madbot_cli.errors

*module*

Errors raised by the madbot client.

Every error of the package derives from `MadbotError`. An error of the API is
an `ApiError`, refined by the HTTP status of the answer, so that a caller can
catch `NotFound` without reading status codes.

The message of an `ApiError` is a sentence for a person: what madbot refused
and what to do next, without the URL or the JSON of the answer. `raw()` gives
the request and the answer, for ``--verbose``; `as_dict()` gives them for
``--json``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L1-1)

## madbot_cli.errors.BODY_EXCERPT

*attribute* · *module attribute*

```python
BODY_EXCERPT = 2000
```

Longest part of an answer kept in the message of an error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L20-20)

## madbot_cli.errors.CREDENTIAL_PARAMETERS

*attribute* · *module attribute*

```python
CREDENTIAL_PARAMETERS = {'credentials', 'private_params'}
```

The parameters of a connection that carry its credentials, given by the environment.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L22-22)

## madbot_cli.errors.ApiError

*class*

```python
class ApiError(MadbotError)
```

Bases: `madbot_cli.errors.MadbotError`

A request to the madbot API failed.

**Attributes**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int or None`) — The HTTP status of the answer, None when the API gave no answer.
- `body` (`Any`) — The answer, decoded from JSON when it is JSON, else its text.
- `code` (`str or None`) — The `code` of a madbot error answer, such as `body_validation_error`.
- `details` (`Any`) — The `details` of a madbot error answer: which parameter is wrong, and why.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int or None`) — The HTTP status of the answer, None when there was no answer.
- `body` (`Any`) — The answer, or what went wrong.
- `message` (`str`) (default: `''`) — A sentence for a person, put before the answer.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L30-191)

### madbot_cli.errors.ApiError.body

*attribute* · *instance attribute*

```python
body = body
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.ApiError.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.ApiError.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.ApiError.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.ApiError.method

*attribute* · *instance attribute*

```python
method = method
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.ApiError.status

*attribute* · *instance attribute*

```python
status = status
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.ApiError.url

*attribute* · *instance attribute*

```python
url = url
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.ApiError.as_dict

*method*

```python
def as_dict() -> dict
```

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.ApiError.explain

*method*

```python
def explain() -> str
```

Say in a sentence what madbot answered, for an error built without a message.

**Returns**

- (`str`) — What madbot refused, from the ``details`` of its answer, without the URL or the JSON.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L78-91)

### madbot_cli.errors.ApiError.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.ApiError.raw

*method*

```python
def raw() -> str
```

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.ApiError.reason

*method*

```python
def reason() -> str
```

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.ApiUnreachable

*class*

```python
class ApiUnreachable(ApiError)
```

Bases: `madbot_cli.errors.ApiError`

The API gave no answer: wrong address, network down, or a timeout.

`attempts` is how many times the request was sent: the client sends again
a request that can be repeated without effect.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L194-237)

### madbot_cli.errors.ApiUnreachable.attempts

*attribute* · *class attribute* · *instance attribute*

```python
attempts: int = 1
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L202-202)

### madbot_cli.errors.ApiUnreachable.body

*attribute* · *instance attribute*

```python
body = body
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.ApiUnreachable.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.ApiUnreachable.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.ApiUnreachable.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.ApiUnreachable.method

*attribute* · *instance attribute*

```python
method = method
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.ApiUnreachable.status

*attribute* · *instance attribute*

```python
status = status
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.ApiUnreachable.url

*attribute* · *instance attribute*

```python
url = url
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.ApiUnreachable.after

*method*

```python
def after(attempts: int) -> ApiUnreachable
```

Say the request was sent several times, in the message too.

**Parameters**

- `attempts` (`int`) — How many times the request was sent.

**Returns**

- (`ApiUnreachable`) — The same error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L204-221)

### madbot_cli.errors.ApiUnreachable.explain

*method*

```python
def explain() -> str
```

Say that madbot could not be reached, and where.

**Returns**

- (`str`) — The host and the reason.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L223-237)

### madbot_cli.errors.ApiUnreachable.as_dict

*method*

```python
def as_dict() -> dict
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.ApiUnreachable.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Inherited from: `madbot_cli.errors.ApiError`

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.ApiUnreachable.raw

*method*

```python
def raw() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.ApiUnreachable.reason

*method*

```python
def reason() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.Conflict

*class*

```python
class Conflict(ApiError)
```

Bases: `madbot_cli.errors.ApiError`

The object is not in a state that allows the request (HTTP 409).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L371-388)

### madbot_cli.errors.Conflict.body

*attribute* · *instance attribute*

```python
body = body
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.Conflict.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.Conflict.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.Conflict.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.Conflict.method

*attribute* · *instance attribute*

```python
method = method
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.Conflict.status

*attribute* · *instance attribute*

```python
status = status
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.Conflict.url

*attribute* · *instance attribute*

```python
url = url
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.Conflict.explain

*method*

```python
def explain() -> str
```

Say madbot cannot do it in the present state, and what to run.

**Returns**

- (`str`) — Why, when madbot says it, and to run status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L374-388)

### madbot_cli.errors.Conflict.as_dict

*method*

```python
def as_dict() -> dict
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.Conflict.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Inherited from: `madbot_cli.errors.ApiError`

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.Conflict.raw

*method*

```python
def raw() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.Conflict.reason

*method*

```python
def reason() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.InvalidRequest

*class*

```python
class InvalidRequest(ApiError)
```

Bases: `madbot_cli.errors.ApiError`

The API refused the request (HTTP 400): see `code` and `details`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L288-310)

### madbot_cli.errors.InvalidRequest.body

*attribute* · *instance attribute*

```python
body = body
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.InvalidRequest.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.InvalidRequest.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.InvalidRequest.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.InvalidRequest.method

*attribute* · *instance attribute*

```python
method = method
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.InvalidRequest.status

*attribute* · *instance attribute*

```python
status = status
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.InvalidRequest.url

*attribute* · *instance attribute*

```python
url = url
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.InvalidRequest.explain

*method*

```python
def explain() -> str
```

Say which parameter madbot refused, and why.

**Returns**

- (`str`) — The parameters refused, and to fix them in the file.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L291-310)

### madbot_cli.errors.InvalidRequest.as_dict

*method*

```python
def as_dict() -> dict
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.InvalidRequest.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Inherited from: `madbot_cli.errors.ApiError`

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.InvalidRequest.raw

*method*

```python
def raw() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.InvalidRequest.reason

*method*

```python
def reason() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.MadbotError

*class*

```python
class MadbotError(Exception)
```

Bases: `Exception`

Base class of the errors of the package.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L26-27)

## madbot_cli.errors.NotFound

*class*

```python
class NotFound(ApiError)
```

Bases: `madbot_cli.errors.ApiError`

The object does not exist, or the account cannot see it (HTTP 404).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L351-368)

### madbot_cli.errors.NotFound.body

*attribute* · *instance attribute*

```python
body = body
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.NotFound.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.NotFound.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.NotFound.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.NotFound.method

*attribute* · *instance attribute*

```python
method = method
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.NotFound.status

*attribute* · *instance attribute*

```python
status = status
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.NotFound.url

*attribute* · *instance attribute*

```python
url = url
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.NotFound.explain

*method*

```python
def explain() -> str
```

Say madbot does not find the object, and what to run.

**Returns**

- (`str`) — Why it may be missing, and to run plan.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L354-368)

### madbot_cli.errors.NotFound.as_dict

*method*

```python
def as_dict() -> dict
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.NotFound.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Inherited from: `madbot_cli.errors.ApiError`

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.NotFound.raw

*method*

```python
def raw() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.NotFound.reason

*method*

```python
def reason() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.NotJson

*class*

```python
class NotJson(ApiError)
```

Bases: `madbot_cli.errors.ApiError`

The API answered something else than JSON, often the web application instead of the API.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L240-241)

### madbot_cli.errors.NotJson.body

*attribute* · *instance attribute*

```python
body = body
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.NotJson.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.NotJson.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.NotJson.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.NotJson.method

*attribute* · *instance attribute*

```python
method = method
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.NotJson.status

*attribute* · *instance attribute*

```python
status = status
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.NotJson.url

*attribute* · *instance attribute*

```python
url = url
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.NotJson.as_dict

*method*

```python
def as_dict() -> dict
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.NotJson.explain

*method*

```python
def explain() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say in a sentence what madbot answered, for an error built without a message.

**Returns**

- (`str`) — What madbot refused, from the ``details`` of its answer, without the URL or the JSON.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L78-91)

### madbot_cli.errors.NotJson.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Inherited from: `madbot_cli.errors.ApiError`

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.NotJson.raw

*method*

```python
def raw() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.NotJson.reason

*method*

```python
def reason() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.PermissionDenied

*class*

```python
class PermissionDenied(ApiError)
```

Bases: `madbot_cli.errors.ApiError`

The account may not do this (HTTP 403).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L331-348)

### madbot_cli.errors.PermissionDenied.body

*attribute* · *instance attribute*

```python
body = body
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.PermissionDenied.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.PermissionDenied.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.PermissionDenied.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.PermissionDenied.method

*attribute* · *instance attribute*

```python
method = method
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.PermissionDenied.status

*attribute* · *instance attribute*

```python
status = status
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.PermissionDenied.url

*attribute* · *instance attribute*

```python
url = url
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.PermissionDenied.explain

*method*

```python
def explain() -> str
```

Say the account may not do it, and whom to ask.

**Returns**

- (`str`) — Why, when madbot says it, and whom to ask.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L334-348)

### madbot_cli.errors.PermissionDenied.as_dict

*method*

```python
def as_dict() -> dict
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.PermissionDenied.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Inherited from: `madbot_cli.errors.ApiError`

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.PermissionDenied.raw

*method*

```python
def raw() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.PermissionDenied.reason

*method*

```python
def reason() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.Redirected

*class*

```python
class Redirected(ApiError)
```

Bases: `madbot_cli.errors.ApiError`

The API sent the request to another address (HTTP 3xx), often ``https://``.

The client does not follow: the token would go to the new address, and a
POST would come back as a GET. `location` is the address given, if any.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L244-285)

### madbot_cli.errors.Redirected.location

*attribute* · *class attribute* · *instance attribute*

```python
location: str | None = None
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L252-252)

### madbot_cli.errors.Redirected.body

*attribute* · *instance attribute*

```python
body = body
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.Redirected.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.Redirected.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.Redirected.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.Redirected.method

*attribute* · *instance attribute*

```python
method = method
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.Redirected.status

*attribute* · *instance attribute*

```python
status = status
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.Redirected.url

*attribute* · *instance attribute*

```python
url = url
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.Redirected.of

*method* · *classmethod*

```python
def of(method: str, url: str, status: int, location: str | None) -> Redirected
```

Build the error, with the address to use instead.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer.
- `location` (`str or None`) — The address the API sends to, None when unknown.

**Returns**

- (`Redirected`) — The error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L254-285)

### madbot_cli.errors.Redirected.as_dict

*method*

```python
def as_dict() -> dict
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.Redirected.explain

*method*

```python
def explain() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say in a sentence what madbot answered, for an error built without a message.

**Returns**

- (`str`) — What madbot refused, from the ``details`` of its answer, without the URL or the JSON.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L78-91)

### madbot_cli.errors.Redirected.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Inherited from: `madbot_cli.errors.ApiError`

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.Redirected.raw

*method*

```python
def raw() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.Redirected.reason

*method*

```python
def reason() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.ServerError

*class*

```python
class ServerError(ApiError)
```

Bases: `madbot_cli.errors.ApiError`

The API failed (HTTP 500 or more).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L391-410)

### madbot_cli.errors.ServerError.body

*attribute* · *instance attribute*

```python
body = body
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.ServerError.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.ServerError.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.ServerError.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.ServerError.method

*attribute* · *instance attribute*

```python
method = method
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.ServerError.status

*attribute* · *instance attribute*

```python
status = status
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.ServerError.url

*attribute* · *instance attribute*

```python
url = url
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.ServerError.explain

*method*

```python
def explain() -> str
```

Say madbot failed, and what to do.

**Returns**

- (`str`) — The status, what madbot says, and to try again then tell the administrators.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L394-410)

### madbot_cli.errors.ServerError.as_dict

*method*

```python
def as_dict() -> dict
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.ServerError.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Inherited from: `madbot_cli.errors.ApiError`

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.ServerError.raw

*method*

```python
def raw() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.ServerError.reason

*method*

```python
def reason() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.TaskFailed

*class*

```python
class TaskFailed(MadbotError)
```

Bases: `madbot_cli.errors.MadbotError`

A background task of madbot ended in failure.

**Attributes**

- `task` (`dict`) — The task as the API returns it, with its `status` and `result`.

**Parameters**

- `task` (`dict`) — The task as the API returns it.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L413-436)

### madbot_cli.errors.TaskFailed.task

*attribute* · *instance attribute*

```python
task = task
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L432-432)

## madbot_cli.errors.Unauthorized

*class*

```python
class Unauthorized(ApiError)
```

Bases: `madbot_cli.errors.ApiError`

The token is missing, unknown or expired (HTTP 401).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L313-328)

### madbot_cli.errors.Unauthorized.body

*attribute* · *instance attribute*

```python
body = body
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L72-72)

### madbot_cli.errors.Unauthorized.code

*attribute* · *instance attribute*

```python
code = body.get('code') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L73-73)

### madbot_cli.errors.Unauthorized.details

*attribute* · *instance attribute*

```python
details = body.get('details') if isinstance(body, dict) else None
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L74-74)

### madbot_cli.errors.Unauthorized.message

*attribute* · *instance attribute*

```python
message = message or self.explain()
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L75-75)

### madbot_cli.errors.Unauthorized.method

*attribute* · *instance attribute*

```python
method = method
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L69-69)

### madbot_cli.errors.Unauthorized.status

*attribute* · *instance attribute*

```python
status = status
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L71-71)

### madbot_cli.errors.Unauthorized.url

*attribute* · *instance attribute*

```python
url = url
```

Inherited from: `madbot_cli.errors.ApiError`

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L70-70)

### madbot_cli.errors.Unauthorized.explain

*method*

```python
def explain() -> str
```

Say the token is refused, and what token to give.

**Returns**

- (`str`) — What to check.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L316-328)

### madbot_cli.errors.Unauthorized.as_dict

*method*

```python
def as_dict() -> dict
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--json`` shows them.

**Returns**

- (`dict`) — ``method``, ``url``, ``status`` and the decoded ``body``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L143-157)

### madbot_cli.errors.Unauthorized.from_answer

*method* · *classmethod*

```python
def from_answer(method: str, url: str, status: int, body: Any) -> ApiError
```

Inherited from: `madbot_cli.errors.ApiError`

Build the error that matches an HTTP status.

**Parameters**

- `method` (`str`) — The HTTP method of the request.
- `url` (`str`) — The URL of the request.
- `status` (`int`) — The HTTP status of the answer, 400 or more.
- `body` (`Any`) — The decoded answer.

**Returns**

- (`ApiError`) — A `InvalidRequest`, `Unauthorized`, `PermissionDenied`, `NotFound`, `Conflict` or `ServerError`, or a plain `ApiError` for another status.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L159-191)

### madbot_cli.errors.Unauthorized.raw

*method*

```python
def raw() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Give the request and the answer, as ``--verbose`` shows them.

**Returns**

- (`str`) — ``METHOD URL -> HTTP status``, then the answer (cut after `BODY_EXCERPT` characters).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L126-141)

### madbot_cli.errors.Unauthorized.reason

*method*

```python
def reason() -> str
```

Inherited from: `madbot_cli.errors.ApiError`

Say why madbot refused, from its answer.

**Returns**

- (`str`) — Each detail of the answer as ``parameter: message``, joined; the ``message`` of the answer when it has no detail; empty when the answer is not a madbot error.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L93-124)

## madbot_cli.errors.WaitTimeout

*class*

```python
class WaitTimeout(MadbotError)
```

Bases: `madbot_cli.errors.MadbotError`

Something madbot does in the background took longer than the client waits.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/errors.py#L439-440)
