Added Network Errors
This commit is contained in:
parent
bb5763deb0
commit
31faf60285
|
@ -36,6 +36,22 @@ enum_from_primitive! {
|
|||
}
|
||||
}
|
||||
|
||||
enum_from_primitive! {
|
||||
#[derive(Debug)]
|
||||
pub enum NetworkError {
|
||||
PeerNotFound = 12544,
|
||||
PostNotFound = 12545,
|
||||
PostDeleted = 12546,
|
||||
AlreadyReposted = 12547,
|
||||
FileUploadError = 12548,
|
||||
DocumentNotFound = 12549,
|
||||
AccessDenied = 12550,
|
||||
BlockedByPeer = 12551,
|
||||
BlockedPeer = 12552,
|
||||
SelfInteractionNotPermitted = 12553,
|
||||
}
|
||||
}
|
||||
|
||||
enum_from_primitive! {
|
||||
#[derive(Debug)]
|
||||
pub enum ServerError {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use super::errors::AuthenticationError;
|
||||
use super::errors::ClientError;
|
||||
use super::errors::NetworkError;
|
||||
use super::errors::RpcError;
|
||||
use super::errors::ServerError;
|
||||
use super::errors::ValidationError;
|
||||
|
@ -19,6 +20,7 @@ pub struct Error {
|
|||
pub enum ErrorKind {
|
||||
Validation(ValidationError),
|
||||
Authentication(AuthenticationError),
|
||||
Network(NetworkError),
|
||||
Server(ServerError),
|
||||
Rpc(RpcError),
|
||||
Cdn(String),
|
||||
|
@ -56,6 +58,11 @@ impl From<ErrorCode> for ErrorKind {
|
|||
Some(kind) => Self::Authentication(kind),
|
||||
None => Self::Unknown,
|
||||
}
|
||||
} else if (12544..=16383).contains(&code) {
|
||||
match NetworkError::from_i32(code) {
|
||||
Some(kind) => Self::Network(kind),
|
||||
None => Self::Unknown,
|
||||
}
|
||||
} else if (16384..).contains(&code) {
|
||||
match ServerError::from_i32(code) {
|
||||
Some(kind) => Self::Server(kind),
|
||||
|
|
Loading…
Reference in New Issue