Skip to content

Commit 8be6cbf

Browse files
committed
update website docs (TCP)
1 parent 9cc06cd commit 8be6cbf

1 file changed

Lines changed: 41 additions & 9 deletions

File tree

docs/python-tcp-ip.md

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,56 @@ $ echo '{ "Kill" : 1 }' | nc localhost 4598
131131

132132
### Error reporting
133133

134-
In case a request cannot be processed, e.g., because the provided JSON is malformed, the provided vectors have incompatible dimensions, the TCP server will return to the client an error report. This is a JSON with three attributes: (i) a key-value pair `"type": "Error"`, to allow the client to tell that an error has occurred, (ii) a `code`, which can be used to uniquely identify the type of error and (iii) a `message`, which offers some human-readable details.
134+
If a request cannot be processed, for example because the JSON payload is
135+
malformed, the request body is not valid UTF-8, or one of the provided vectors
136+
has the wrong dimension, the TCP server returns an error report instead of a
137+
solution.
135138

136-
For example, if the client provides an incompatible number of parameters, that is, if vector `parameter` is of the wrong length, then the server will return the following error:
139+
The error report is a JSON document with three fields:
140+
141+
- `"type": "Error"` so the client can distinguish errors from successful solver
142+
responses
143+
- `code`, a machine-readable integer code
144+
- `message`, a human-readable string with more context
145+
146+
In particular, the `message` field is now intended to be descriptive. For
147+
dimension-related errors it includes the provided and expected lengths, and for
148+
solver failures it includes the underlying solver-side reason whenever
149+
available.
150+
151+
For example, if the client provides an incompatible number of parameters, that
152+
is, if vector `parameter` has the wrong length, the server returns an error like
153+
the following:
154+
155+
```json
156+
{
157+
"type": "Error",
158+
"code": 3003,
159+
"message": "wrong number of parameters: provided 1, expected 2"
160+
}
161+
```
162+
163+
Likewise, if the solver itself fails, the server returns code `2000` together
164+
with the propagated solver reason, for example:
137165

138166
```json
139167
{
140-
"type": "Error",
141-
"code": 3003,
142-
"message": "wrong number of parameters"
168+
"type": "Error",
169+
"code": 2000,
170+
"message": "problem solution failed: non-finite computation: gradient evaluation returned a non-finite value during an FBS step"
143171
}
144172
```
145173

146-
The following errors may be returned to the client
174+
The following error codes may be returned to the client:
147175

148176
| Code | Explanation |
149177
|-----------|---------------------------------------------|
150-
| 1000 | Invalid request: Malformed or invalid JSON |
178+
| 1000 | Invalid request: malformed JSON or invalid UTF-8 payload |
151179
| 1600 | Initial guess has incompatible dimensions |
152-
| 1700 | Wrong dimension of Langrange multipliers |
153-
| 2000 | Problem solution failed (solver error) |
180+
| 1700 | Wrong dimension of Lagrange multipliers |
181+
| 2000 | Problem solution failed; the message contains the solver-side reason |
154182
| 3003 | Vector `parameter` has wrong length |
183+
184+
When using the Python TCP client, these responses are surfaced as
185+
`opengen.tcp.solver_error.SolverError`, whose `code` and `message` properties
186+
mirror the JSON payload returned by the TCP server.

0 commit comments

Comments
 (0)