Print WebSocket errors when we get them (#2018)

* Print WebSocket errors when we get them

Previously, we eat them and ignore them, but now we'll seek out
and actively print error messages to stderr. We'd previously get a
websocket closed error, but we'll usually get an Error message over the
WebSocket before its closed on us.

Here's some example output during a crash

```
got ws error: WebSocket protocol error: Connection reset without closing handshake

Caused by:
    Connection reset without closing handshake
thread 'serial_test_cube_mm' panicked at tests/executor/main.rs:1136:10:
called `Result::unwrap()` on an `Err` value: engine: KclErrorDetails { source_ranges: [SourceRange([180, 188])], message: "Modeling command failed: websocket closed early" }
test serial_test_cube_mm ... FAILED
got error message: {
  "error_code": "bad_request",
  "message": "Too many active connections, only 2 allowed per user."
}
```
This commit is contained in:
Paul Tagliamonte
2024-04-04 14:47:47 -04:00
committed by GitHub
parent 594e888c12
commit f493cf11a0
7 changed files with 3 additions and 0 deletions

View File

@ -135,6 +135,9 @@ impl EngineConnection {
loop {
match tcp_read.read().await {
Ok(ws_resp) => {
for e in ws_resp.errors.iter().flatten() {
println!("got error message: {e}");
}
if let Some(id) = ws_resp.request_id {
responses_clone.insert(id, ws_resp.clone());
}