mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 09:05:45 +00:00
reorganize error types, return socket_connection on init error
This commit is contained in:
parent
44196608ce
commit
cc1018224a
2 changed files with 16 additions and 10 deletions
|
|
@ -74,7 +74,7 @@ impl Client {
|
||||||
move |result| match result {
|
move |result| match result {
|
||||||
Ok(socket_connection) => {
|
Ok(socket_connection) => {
|
||||||
match Connection::build(
|
match Connection::build(
|
||||||
socket_connection,
|
socket_connection.clone(),
|
||||||
network_address,
|
network_address,
|
||||||
client_certificate,
|
client_certificate,
|
||||||
server_certificates,
|
server_certificates,
|
||||||
|
|
@ -87,18 +87,20 @@ impl Client {
|
||||||
move |result| {
|
move |result| {
|
||||||
callback(match result {
|
callback(match result {
|
||||||
Ok(response) => Ok(response),
|
Ok(response) => Ok(response),
|
||||||
Err(e) => Err(Error::Connection(e)),
|
Err(e) => Err(Error::Request(e)),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Err(e) => callback(Err(Error::Connection(e))),
|
Err(e) => {
|
||||||
|
callback(Err(Error::Connection(socket_connection, e)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => callback(Err(Error::Connect(e))),
|
Err(e) => callback(Err(Error::Connect(e))),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Err(e) => callback(Err(Error::Request(e))),
|
Err(e) => callback(Err(Error::NetworkAddress(e))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,25 @@ use std::fmt::{Display, Formatter, Result};
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Connect(glib::Error),
|
Connect(glib::Error),
|
||||||
Connection(crate::client::connection::Error),
|
Connection(gio::SocketConnection, crate::client::connection::Error),
|
||||||
Request(crate::client::connection::request::Error),
|
NetworkAddress(crate::client::connection::request::Error),
|
||||||
|
Request(crate::client::connection::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||||
match self {
|
match self {
|
||||||
Self::Connection(e) => {
|
|
||||||
write!(f, "Connection error: {e}")
|
|
||||||
}
|
|
||||||
Self::Connect(e) => {
|
Self::Connect(e) => {
|
||||||
write!(f, "Connect error: {e}")
|
write!(f, "Connect error: {e}")
|
||||||
}
|
}
|
||||||
|
Self::Connection(_, e) => {
|
||||||
|
write!(f, "Connection init error: {e}")
|
||||||
|
}
|
||||||
|
Self::NetworkAddress(e) => {
|
||||||
|
write!(f, "Network address error: {e}")
|
||||||
|
}
|
||||||
Self::Request(e) => {
|
Self::Request(e) => {
|
||||||
write!(f, "Request error: {e}")
|
write!(f, "Connection error: {e}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue