networkdoctor: start diagnosing curl errors

Summary: I hit a curl timeout error on the shuttle when testing. Now we handle that and give a generic "check your network" message. It is possible it is a server problem, but I think much more likely a local network issue.

Reviewed By: DurhamG

Differential Revision: D34803930

fbshipit-source-id: 0936f6a0b96a26fb7afdc89f093a867198650efc
This commit is contained in:
Muir Manders 2022-03-17 11:11:53 -07:00 committed by Facebook GitHub Bot
parent c75c87afe9
commit 024e861b20
2 changed files with 13 additions and 1 deletions

View File

@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
auth = { version = "0.1.0", path = "../../auth" }
configmodel = { version = "0.1.0", path = "../../configmodel" }
curl = { version = "0.4.41", features = ["http2"] }
hg-http = { version = "0.1.0", path = "../../hg-http" }
http = "0.2"
http-client = { version = "0.1.0", path = "../../http-client" }

View File

@ -152,7 +152,18 @@ fn diagnose_http_error(config: &dyn Config, err: &HttpError) -> String {
),
HttpError::InvalidCert(err, _) => maybe_append_help(format!("{}", err), "tlsauthhelp"),
HttpError::MissingCerts(err) => maybe_append_help(format!("{}", err), "tlsauthhelp"),
_ => format!("{}", err),
HttpError::RequestFailure(HttpClientError::Curl(err)) => diagnose_curl_error(err),
HttpError::Config(err) => err.to_string(),
HttpError::RequestFailure(_) => format!("{}", err),
}
}
fn diagnose_curl_error(err: &curl::Error) -> String {
if err.is_operation_timedout() {
"Network timeout. Please check your connection.".to_string()
} else {
format!("{}", err)
}
}