melib/jmap: show suggestions on Unauthorized error

Show suggestions for solving Unauthorized connection errors.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/425/head
Manos Pitsidianakis 4 months ago
parent 15f3a3fba6
commit 6e1fea8059
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -156,11 +156,21 @@ impl JmapConnection {
if !req.status().is_success() {
let kind: crate::error::NetworkErrorKind = req.status().into();
let res_text = req.text().await.unwrap_or_default();
let err = Error::new(format!(
let mut err = Error::new(format!(
"Could not connect to JMAP server endpoint for {}. Reply from server: {}",
&self.server_conf.server_url, res_text
))
.set_kind(kind.into());
if matches!(err.kind, ErrorKind::Network(NetworkErrorKind::Unauthorized)) {
err = err.set_details(
"The server rejected your authentication credentials. Check your provider's \
client connection documentation and see if the following common reasons for \
this error apply:\n- Using the account password when a Bearer token is \
required (You must set `use_token=true` in this case)\n- Using a Bearer \
token is required when a password is expected (You must set \
`use_token=false`)\n- Using invalid password or token value.",
);
}
_ = self
.store
.online_status

Loading…
Cancel
Save