Skip to content

Commit 318f810

Browse files
committed
Specify correct request failure reason and raise timeout
1 parent 65a2487 commit 318f810

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
A blazingly fast, interactive AI coding assistant powered by Claude, implemented in pure Rust, that can generate code, edit files, and search the web - all from your terminal.
66

7-
<div align="center"><img src="/assets/sofos_code.png" style="width: 800px;" alt="Ferrocrypt"></div>
7+
<div align="center"><img src="/assets/sofos_code.png" style="width: 800px;" alt="Sofos Code"></div>
88

99
## Features
1010

src/api/client.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::time::Duration;
88

99
const API_BASE: &str = "https://api.anthropic.com/v1";
1010
const API_VERSION: &str = "2023-06-01";
11-
const REQUEST_TIMEOUT: Duration = Duration::from_secs(120);
11+
const REQUEST_TIMEOUT: Duration = Duration::from_secs(300);
1212
const MAX_RETRIES: u32 = 2;
1313
const INITIAL_RETRY_DELAY_MS: u64 = 1000;
1414

@@ -85,14 +85,25 @@ impl AnthropicClient {
8585
let url = format!("{}/messages", API_BASE);
8686

8787
// Try with retries
88-
let mut last_error = None;
88+
let mut last_error: Option<reqwest::Error> = None;
8989
let mut retry_delay = Duration::from_millis(INITIAL_RETRY_DELAY_MS);
9090

9191
for attempt in 0..=MAX_RETRIES {
9292
if attempt > 0 {
93+
let reason = if let Some(ref err) = last_error {
94+
if err.is_timeout() {
95+
"Request timed out"
96+
} else {
97+
&*format!("Request failed: {}", err)
98+
}
99+
} else {
100+
"Request failed"
101+
};
102+
93103
eprintln!(
94-
"\n{} Request failed, retrying in {:?}... (attempt {}/{})",
104+
" {} {}, retrying in {:?}... (attempt {}/{})",
95105
"Network:".bright_yellow(),
106+
reason,
96107
retry_delay,
97108
attempt,
98109
MAX_RETRIES

0 commit comments

Comments
 (0)