From bd405d725b6fb7713bd240da3bb4aff3e6e5b58f Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Sat, 16 Nov 2019 15:56:14 +0400 Subject: [PATCH] Add protocol error processing mechanism --- protocol-spec/core.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/protocol-spec/core.md b/protocol-spec/core.md index c6336b1..a5a7547 100644 --- a/protocol-spec/core.md +++ b/protocol-spec/core.md @@ -25,4 +25,43 @@ from (EntityID) - from which entity this message is send to (EntityID) - message recipient ok (boolean) - operation success indicator (used to determine if errors was happened when processing request) payload (Map) - message payload (used to store extra information in message, list of permissible fields in the payload are depends on "type" field) +``` + +## Errors +Mechanism of error processing included into protocol. +Adds into type name `:error` postfix. + +**Payload**: +* `errCode: int` - error code (defined in extensions. Error code which defined in the specific extension MUST NOT overlap with other error codes) +* `errText: String` - explanation of error in human-readable view +* `errPayload: Map` - advanced error information (fields defined in extensions) + +**Example**: + +*Request*: +```json +{ + "id": "abcd", + "type": "incorrectMessageType", + "from": "@juliet@cadmium.im", + "to": "cadmium.im", + "payload": { + "test": "test" + } +} +``` + +*Response*: +```json +{ + "id": "abcd", + "type": "incorrectMessageType:error", + "from": "cadmium.im", + "to": "@juliet@cadmium.im", + "payload": { + "errCode": 0, + "errText": "Incorrect type of message (type isn't implemented in the server)", + "errPayload": {} + } +} ``` \ No newline at end of file