Skip to content

Commit fc490c5

Browse files
authored
Merge pull request #51 from pragmatrix/improve-session-error-reporting
Improve openai session creation error handling
2 parents d8e1815 + b3fe2b7 commit fc490c5

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "context-switch"
3-
version = "1.1.1"
3+
version = "1.1.2"
44
edition = "2024"
55
rust-version = "1.88"
66

audio-knife/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "audio-knife"
3-
version = "1.4.1"
3+
version = "1.4.2"
44
edition = "2024"
55

66
[profile.dev]

services/openai-dialog/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "openai-dialog"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2024"
55

66
[dependencies]

services/openai-dialog/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,15 @@ impl Client {
345345
};
346346

347347
let initial = serde_json::from_str(&message)?;
348-
let ServerEvent::SessionCreated(session_created) = initial else {
349-
bail!("Failed to receive the session created event");
348+
let session_created = match initial {
349+
ServerEvent::SessionCreated(session_created) => session_created,
350+
ServerEvent::Error(e) => {
351+
let error_message = e.error.message;
352+
bail!("Failed to create the session: {error_message}");
353+
}
354+
_ => {
355+
bail!("Received an unexpected event in response to the session creation");
356+
}
350357
};
351358

352359
let session = session_created.session;

0 commit comments

Comments
 (0)