diff options
Diffstat (limited to 'crates/shirabe/src/repository/vcs/svn_driver.rs')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/svn_driver.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index a793340..23ea703 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -171,7 +171,6 @@ impl SvnDriver { } } - // TODO(phase-b): use anyhow::Result<Result<T, E>> to model PHP try/catch let base_result = self.get_file_content("composer.json", identifier) .and_then(|file_content| { @@ -184,9 +183,15 @@ impl SvnDriver { let composer: Option<IndexMap<String, PhpMixed>> = match base_result { Ok(c) => c, Err(e) => { - // TODO(phase-b): downcast to TransportException - let _te: &TransportException = todo!("downcast e to TransportException"); - let message = e.to_string(); + // PHP catches only TransportException; other exceptions propagate uncaught. + if e.downcast_ref::<TransportException>().is_none() { + return Err(e); + } + let message = e + .downcast_ref::<TransportException>() + .unwrap() + .message + .clone(); if stripos(&message, "path not found").is_none() && stripos(&message, "svn: warning: W160013").is_none() { @@ -253,14 +258,16 @@ impl SvnDriver { (identifier.clone(), String::new()) }; - // TODO(phase-b): use anyhow::Result<Result<T, E>> to model PHP try/catch let output: String = match self.execute( vec!["svn".to_string(), "cat".to_string()], &format!("{}{}{}", self.base_url, path, rev), ) { Ok(o) => o, Err(e) => { - return Err(TransportException::new(e.to_string(), 0).into()); + if let Some(e) = e.downcast_ref::<RuntimeException>() { + return Err(TransportException::new(e.message.clone(), 0).into()); + } + return Err(e); } }; if trim(&output, None) == "" { @@ -551,7 +558,6 @@ impl SvnDriver { .set_cache_credentials(self.cache_credentials); } - // TODO(phase-b): use anyhow::Result<Result<T, E>> to model PHP try/catch match self .util .as_mut() |
