Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions crates/remote_server/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,20 @@ impl Error {
/// SSH remote-server failed banner, using `stage` to provide
/// context-appropriate copy.
pub fn user_facing_error(&self, stage: SetupStage) -> UserFacingError {
if matches!(self, Self::TimedOut) {
return UserFacingError {
body: format!("Timed out while trying to {}", stage.action_description()),
detail: Some(
"Warp stopped waiting for the SSH extension to respond. Your SSH session is \
still running, but advanced features are unavailable for now."
.into(),
),
};
}

let body = format!("Failed to {}", stage.action_description());
let detail = match self {
Self::TimedOut => {
Some("The operation timed out — check your network connection".into())
}
Self::TimedOut => unreachable!("handled above"),
Self::UnsupportedOs { os } => Some(format!("Unsupported OS: {os}")),
Self::UnsupportedArch { arch } => Some(format!("Unsupported architecture: {arch}")),
Self::ScriptFailed { exit_code, stderr } => {
Expand Down Expand Up @@ -279,3 +288,7 @@ pub trait RemoteTransport: Send + Sync + std::fmt::Debug {
/// the reconnect loop entirely.
fn is_reconnectable(&self, exit_status: Option<&RemoteServerExitStatus>) -> bool;
}

#[cfg(test)]
#[path = "transport_tests.rs"]
mod tests;
26 changes: 26 additions & 0 deletions crates/remote_server/src/transport_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use super::*;

#[test]
fn timed_out_error_copy_leads_with_timeout() {
let error = Error::TimedOut.user_facing_error(SetupStage::Launch);

assert_eq!(error.body, "Timed out while trying to start SSH extension");
assert_eq!(
error.detail.as_deref(),
Some(
"Warp stopped waiting for the SSH extension to respond. Your SSH session is \
still running, but advanced features are unavailable for now."
)
);
}

#[test]
fn non_timeout_error_copy_still_leads_with_failure() {
let error = Error::UnsupportedOs {
os: "plan9".to_string(),
}
.user_facing_error(SetupStage::CheckBinary);

assert_eq!(error.body, "Failed to verify SSH extension");
assert_eq!(error.detail.as_deref(), Some("Unsupported OS: plan9"));
}