2019-12-15 16:21:43 +00:00
|
|
|
# Protocol Errors
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
## Introduction
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
Mechanism of error processing included into protocol.
|
2019-12-16 13:14:18 +00:00
|
|
|
Adds into any response message `ok` variable. If `ok` is true - we have no errors, if `ok` is false - we have an error.
|
2019-12-15 16:21:43 +00:00
|
|
|
|
|
|
|
## Message type identifiers
|
2019-12-22 14:39:30 +00:00
|
|
|
|
|
|
|
None.
|
2019-12-15 16:21:43 +00:00
|
|
|
|
|
|
|
## Use cases
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
*Request*:
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "abcd",
|
|
|
|
"type": "incorrectMessageType",
|
|
|
|
"from": "@juliet@cadmium.im",
|
|
|
|
"to": "cadmium.im",
|
|
|
|
"payload": {
|
|
|
|
"test": "test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
*Response*:
|
2019-12-22 14:39:30 +00:00
|
|
|
|
2019-12-15 16:21:43 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "abcd",
|
2019-12-16 13:14:18 +00:00
|
|
|
"type": "incorrectMessageType",
|
2019-12-15 16:21:43 +00:00
|
|
|
"from": "cadmium.im",
|
|
|
|
"to": "@juliet@cadmium.im",
|
2019-12-16 13:14:18 +00:00
|
|
|
"ok": false,
|
2019-12-15 16:21:43 +00:00
|
|
|
"payload": {
|
2020-07-16 08:04:56 +00:00
|
|
|
"errID": "unhandled",
|
2019-12-15 16:21:43 +00:00
|
|
|
"errText": "Incorrect type of message (type isn't implemented in the server)",
|
|
|
|
"errPayload": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## JSON Schema
|
2019-12-22 14:39:30 +00:00
|
|
|
|
|
|
|
### Payload
|
2019-12-15 16:21:43 +00:00
|
|
|
|
|
|
|
```typescript
|
|
|
|
interface ErrorPayload {
|
|
|
|
/**
|
2019-12-26 13:39:16 +00:00
|
|
|
* Error identifier (defined in extensions, maybe same per extensions)
|
2019-12-15 16:21:43 +00:00
|
|
|
*/
|
2020-07-16 08:04:56 +00:00
|
|
|
errID: string,
|
2019-12-15 16:21:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Explanation of error in human-readable view
|
|
|
|
*/
|
|
|
|
errText: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Advanced error information (fields defined in extensions)
|
|
|
|
*/
|
|
|
|
errPayload: Map<K,V>
|
|
|
|
}
|
2019-12-22 14:39:30 +00:00
|
|
|
```
|