mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-15 17:21:19 +10:00
feat: better error message if cannot connect to provided url
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
any::{Any, TypeId},
|
||||||
error::Error,
|
error::Error,
|
||||||
fmt::{Display, Formatter},
|
fmt::{Display, Formatter},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@ -28,16 +29,22 @@ pub enum RemoteAccessError {
|
|||||||
impl Display for RemoteAccessError {
|
impl Display for RemoteAccessError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
RemoteAccessError::FetchError(error) => write!(
|
RemoteAccessError::FetchError(error) => {
|
||||||
f,
|
if error.is_connect() {
|
||||||
"{}: {}",
|
return write!(f, "Failed to connect to Drop server. Check if you access Drop through a browser, and then try again.");
|
||||||
error,
|
}
|
||||||
error
|
|
||||||
.source()
|
write!(
|
||||||
.map(|e| e.to_string())
|
f,
|
||||||
.or_else(|| Some("Unknown error".to_string()))
|
"{}: {}",
|
||||||
.unwrap()
|
error,
|
||||||
),
|
error
|
||||||
|
.source()
|
||||||
|
.map(|e| e.to_string())
|
||||||
|
.or_else(|| Some("Unknown error".to_string()))
|
||||||
|
.unwrap()
|
||||||
|
)
|
||||||
|
},
|
||||||
RemoteAccessError::ParsingError(parse_error) => {
|
RemoteAccessError::ParsingError(parse_error) => {
|
||||||
write!(f, "{}", parse_error)
|
write!(f, "{}", parse_error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user