cadmium-docs-legacy/protocol-spec/protocol-errors.md
2019-12-22 18:40:12 +04:00

1.1 KiB

Protocol Errors

Introduction

Mechanism of error processing included into protocol.
Adds into any response message ok variable. If ok is true - we have no errors, if ok is false - we have an error.

Message type identifiers

None.

Use cases

Request:

{
    "id": "abcd",
    "type": "incorrectMessageType",
    "from": "@juliet@cadmium.im",
    "to": "cadmium.im",
    "payload": {
        "test": "test"
    }
}

Response:

{
    "id": "abcd",
    "type": "incorrectMessageType",
    "from": "cadmium.im",
    "to": "@juliet@cadmium.im",
    "ok": false,
    "payload": {
        "errCode": 0,
        "errText": "Incorrect type of message (type isn't implemented in the server)",
        "errPayload": {}
    }
}

JSON Schema

Payload

interface ErrorPayload {
    /**
     * Error code (defined in extensions, may be same per extensions)
     */
    errCode: number,

    /**
     * Explanation of error in human-readable view
     */
    errText: string,

    /**
     * Advanced error information (fields defined in extensions)
     */
    errPayload: Map<K,V>
}