refactor(backend): replace unsafe unwrap calls with proper error handling
- Add to_json_string helper for safe JSON serialization - Add lock_conn macro for safe Mutex locking - Replace 41 unwrap() calls with proper error handling: - database.rs: JSON serialization and Mutex operations (31 fixes) - lib.rs: macOS NSWindow and tray icon handling (3 fixes) - services/provider.rs: Claude model normalization (1 fix) - services/prompt.rs: timestamp generation (3 fixes) - services/skill.rs: directory name extraction (2 fixes) - mcp.rs: HashMap initialization and type conversions (5 fixes) - app_config.rs: timestamp fallback (1 fix) This improves application stability and prevents potential panics.
This commit is contained in:
@@ -424,9 +424,9 @@ impl ProviderService {
|
||||
/// 归一化 Claude 模型键:读旧键(ANTHROPIC_SMALL_FAST_MODEL),写新键(DEFAULT_*), 并删除旧键
|
||||
fn normalize_claude_models_in_value(settings: &mut Value) -> bool {
|
||||
let mut changed = false;
|
||||
let env = match settings.get_mut("env") {
|
||||
Some(v) if v.is_object() => v.as_object_mut().unwrap(),
|
||||
_ => return changed,
|
||||
let env = match settings.get_mut("env").and_then(|v| v.as_object_mut()) {
|
||||
Some(obj) => obj,
|
||||
None => return changed,
|
||||
};
|
||||
|
||||
let model = env
|
||||
|
||||
Reference in New Issue
Block a user