Skip to content

Commit 4688191

Browse files
committed
REF: Improve error handling in ssh_backend.rs
- Updated error conversion in `list_remote_dir` to use `to_string()` for consistent error formatting. - Added conditional `HashMap` import for test scenarios to improve code modularity and coverage.
1 parent f496178 commit 4688191

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/app/ssh_backend.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ use anyhow::{Context, Result};
55
use crate::model::{ConnectionConfig, OpenConnection, RemoteEntry};
66
use crate::ssh::connect_ssh;
77

8+
#[cfg(test)]
9+
use std::collections::HashMap;
10+
811
pub(crate) trait SshBackend: Send + Sync {
912
fn list_remote_dir(
1013
&self,
@@ -199,7 +202,7 @@ impl SshBackend for MockSshBackend {
199202
_show_hidden: bool,
200203
) -> Result<Vec<RemoteEntry>> {
201204
if let Some(err) = self.list_errors.lock().unwrap().get(cwd) {
202-
return Err(anyhow::anyhow!(err.clone()));
205+
return Err(anyhow::anyhow!(err.to_string()));
203206
}
204207
Ok(self
205208
.list

0 commit comments

Comments
 (0)