mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix format and clippy warnings
This commit is contained in:
@ -18,7 +18,9 @@ pub struct FlowyError {
|
||||
macro_rules! static_flowy_error {
|
||||
($name:ident, $code:expr) => {
|
||||
#[allow(non_snake_case, missing_docs)]
|
||||
pub fn $name() -> FlowyError { $code.into() }
|
||||
pub fn $name() -> FlowyError {
|
||||
$code.into()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -81,7 +83,9 @@ where
|
||||
}
|
||||
|
||||
impl fmt::Display for FlowyError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}: {}", &self.code, &self.msg) }
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}: {}", &self.code, &self.msg)
|
||||
}
|
||||
}
|
||||
|
||||
impl lib_dispatch::Error for FlowyError {
|
||||
@ -92,9 +96,13 @@ impl lib_dispatch::Error for FlowyError {
|
||||
}
|
||||
|
||||
impl std::convert::From<std::io::Error> for FlowyError {
|
||||
fn from(error: std::io::Error) -> Self { FlowyError::internal().context(error) }
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
FlowyError::internal().context(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<protobuf::ProtobufError> for FlowyError {
|
||||
fn from(e: protobuf::ProtobufError) -> Self { FlowyError::internal().context(e) }
|
||||
fn from(e: protobuf::ProtobufError) -> Self {
|
||||
FlowyError::internal().context(e)
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ fn server_error_to_flowy_error(code: ServerErrorCode) -> ErrorCode {
|
||||
ServerErrorCode::RecordNotFound => ErrorCode::RecordNotFound,
|
||||
ServerErrorCode::ConnectRefused | ServerErrorCode::ConnectTimeout | ServerErrorCode::ConnectClose => {
|
||||
ErrorCode::ConnectError
|
||||
},
|
||||
}
|
||||
_ => ErrorCode::Internal,
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
use crate::FlowyError;
|
||||
|
||||
impl std::convert::From<flowy_collaboration::errors::CollaborateError> for FlowyError {
|
||||
fn from(error: flowy_collaboration::errors::CollaborateError) -> Self { FlowyError::internal().context(error) }
|
||||
fn from(error: flowy_collaboration::errors::CollaborateError) -> Self {
|
||||
FlowyError::internal().context(error)
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,21 @@
|
||||
use crate::FlowyError;
|
||||
|
||||
impl std::convert::From<flowy_database::Error> for FlowyError {
|
||||
fn from(error: flowy_database::Error) -> Self { FlowyError::internal().context(error) }
|
||||
fn from(error: flowy_database::Error) -> Self {
|
||||
FlowyError::internal().context(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<::r2d2::Error> for FlowyError {
|
||||
fn from(error: r2d2::Error) -> Self { FlowyError::internal().context(error) }
|
||||
fn from(error: r2d2::Error) -> Self {
|
||||
FlowyError::internal().context(error)
|
||||
}
|
||||
}
|
||||
|
||||
// use diesel::result::{Error, DatabaseErrorKind};
|
||||
// use lib_sqlite::ErrorKind;
|
||||
impl std::convert::From<lib_sqlite::Error> for FlowyError {
|
||||
fn from(error: lib_sqlite::Error) -> Self { FlowyError::internal().context(error) }
|
||||
fn from(error: lib_sqlite::Error) -> Self {
|
||||
FlowyError::internal().context(error)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
use crate::FlowyError;
|
||||
|
||||
impl std::convert::From<lib_ot::errors::OTError> for FlowyError {
|
||||
fn from(error: lib_ot::errors::OTError) -> Self { FlowyError::internal().context(error) }
|
||||
fn from(error: lib_ot::errors::OTError) -> Self {
|
||||
FlowyError::internal().context(error)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
use crate::FlowyError;
|
||||
|
||||
impl std::convert::From<serde_json::Error> for FlowyError {
|
||||
fn from(error: serde_json::Error) -> Self { FlowyError::internal().context(error) }
|
||||
fn from(error: serde_json::Error) -> Self {
|
||||
FlowyError::internal().context(error)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user