Skip to content

Commit 866dfbb

Browse files
committed
fix(input): Improve error message for missing Gemini API key
- Update the error handling for missing Gemini API key to provide clearer instructions. - Include the path to the user configuration file in the error message, guiding users on where to add their API key. - Enhance the visibility of the error message in the popup for better user experience.
1 parent aa2fab5 commit 866dfbb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/input.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,12 @@ pub fn handle_key(
385385
}
386386
// Check for Gemini API key before spawning async task
387387
if std::env::var("GEMINI_API_KEY").is_err() {
388-
let mut p = popup_quote.lock().unwrap();
389-
p.visible = true;
390-
p.loading = false;
391-
p.text = "Gemini API key not found. Please set the GEMINI_API_KEY environment variable.\nExample: export GEMINI_API_KEY=<YOUR API KEY>".to_string();
388+
let config_path = crate::config::get_user_config_path();
389+
let error_message = format!(
390+
"Gemini API key not found.\n\nPlease add it to your configuration file at:\n{}\n\nOr set it as an environment variable: export GEMINI_API_KEY=your-key",
391+
config_path.display()
392+
);
393+
popup_quote.lock().unwrap().text = error_message;
392394
return Ok(true);
393395
}
394396
let p2 = popup_quote.clone();

0 commit comments

Comments
 (0)