This is fully anonymous (except maybe IP) and is only used to improve the library
and developer experience for everyone working with MTProto.
To enable, pass `enableErrorReporting: true` to the client options:
```ts
const tg = new TelegramClient({
...
enableErrorReporting: true
})
```
### Errors with parameters
Some errors (like `FLOOD_WAIT_%d`) also contain a parameter.
This parameter is available as error's field (in this case in `.seconds` field)
after checking for error type using `.is()`:
```ts
try {
// your code //
} catch (e) {
if (tl.RpcError.is(e, 'FLOOD_WAIT_%d')) {
await new Promise((res) => setTimeout(res, e.seconds))
} else throw e
}
```
## mtcute errors
mtcute has a group of its own errors that are used to indicate
that the provided input is invalid, or that the server
returned something weird.
All these errors are subclassed from `MtcuteError`:
| Name | Description | Package |
|---|---|---|
| `MtArgumentError` | Some argument passed to the method appears to be incorrect in some way | core
| `MtSecurityError` | Something isn't right with security of the connection | core
| `MtUnsupportedError` | Server returned something that mtcute does not support (yet). Should not normally happen, and if it does, feel free to [open an issue](https://github.com/mtcute/mtcute/issues/new). | core
| `MtTypeAssertionError`| Server returned some type, but mtcute expected it to be another type. Usually means a bug on mtcute side, so feel free to [open an issue](https://github.com/mtcute/mtcute/issues/new).
| `MtTimeoutError` | Timeout for the request has been reached | core
| `MtPeerNotFoundError` | Only thrown by `resolvePeer`. Means that mtcute wasn't able to find a peer for a given `InputPeerLike`. | client
| `MtMessageNotFoundError` | mtcute hasn't been able to find a message by the given parameters | client
| `MtInvalidPeerTypeError` | mtcute expected another type of peer (e.g. you provided a user, but a channel was expected). | client
| `MtEmptyError` | You tried to access some property that is not available on the object | client
## Client errors
Even though these days internet is much more stable than before,
stuff like "Error: Connection reset" still happens.
Also, there might be some client-level error that happened internally
(e.g. error while processing updates).
You can handle these errors using `TelegramClient#onError`: