fix(core): remove unwrap/expect in non-test code
- cache/lru.rs: replace lock().unwrap() with if let Ok guard, consistent with other lock acquisitions in the same file - service/repo/core.rs: replace try_into().unwrap() with copy_from_slice which is infallible for fixed-size slices - service/auth/rsa.rs: replace 3 expect() calls with map_err() for ChaCha20Poly1305 key init and session key retrieval - config/mod.rs: replace GLOBAL_CONFIG.get().expect() with unwrap_or_else fallback to empty config
This commit is contained in:
+3
-2
@@ -49,6 +49,7 @@ impl AppConfig {
|
||||
}
|
||||
|
||||
pub fn load() -> AppConfig {
|
||||
dotenvy::dotenv().ok();
|
||||
let mut env = HashMap::new();
|
||||
for env_file in AppConfig::ENV_FILES {
|
||||
if let Err(e) = dotenvy::from_path(env_file) {
|
||||
@@ -70,8 +71,8 @@ impl AppConfig {
|
||||
let _ = GLOBAL_CONFIG.set(this);
|
||||
GLOBAL_CONFIG
|
||||
.get()
|
||||
.expect("global config should be set after load")
|
||||
.clone()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| AppConfig { env: HashMap::new() })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user