Commit fe2b7b8f authored by Jesse Bakker's avatar Jesse Bakker

Add error codes

parent 6e70ad02
......@@ -9,6 +9,7 @@ We specify the program flow, format and different kinds of messages, all with li
1. [Program flow](#program-flow)
2. [Format](#format)
3. [Messages](#messages)
4. [Error codes](#error-codes)
## Program flow
......@@ -21,7 +22,7 @@ The chosen format is [JSON](https://wikipedia.org/wiki/JSON). This format is nic
```json
{
"id": <request id>,
"method": "<method name>",
"method": <method name>,
"params": <param object>
}
```
......@@ -35,16 +36,30 @@ The chosen format is [JSON](https://wikipedia.org/wiki/JSON). This format is nic
```json
{
"id": <request id>,
"method": "<method name>",
"params": <param object>
"result": <optional result object>,
"error": <optional error object>
}
```
A request can either succeed or fail. In case it succeeds, it is possible to return a result, which is specified in the message specification for the respective method. If no result is defined, the result field is not required.
In case the request fails, the response will contain the error field, of which the format is specified below.
### Error format
```json
{
"code": <error code (integer)>,
"message": <optional error message>
}
```
To distinguish between different kinds of errors, an error code is returned. The possible error codes are defined [here](#error-codes). The error can also optionally include a message, which can be used for example for debugging.
### Notification format
```json
{
"method": "<method name>",
"method": <method name>,
"params": <param object>
}
```
......@@ -182,8 +197,8 @@ class Coordinate {
_Errors_:
- ERROR_INVALID_LANCE
- ERROR_INVALID_MOVE
- The lance is invalid, because it is too long, does not just contain the player's own/team's marbles or is not in a straight line: `ERROR_INVALID_LANCE`
- The given lance cannot move to the specified coordinate, e.g. because it moves more than one field over, moves off the board, or is blocked: `ERROR_INVALID_MOVE`
#### End game
......@@ -197,3 +212,13 @@ class EndGameParams {
Optional<int|char> winner;
}
```
## Error codes
```java
class ErrorCodes {
int ERROR_ROOM_FULL = 0;
int ERROR_TEAM_FULL = 1;
int ERROR_INVALID_LANCE = 2;
int ERROR_INVALID_MOVE = 3;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment