refactor errors

This commit is contained in:
appflowy
2021-12-14 18:04:51 +08:00
parent 72a8f7a9e3
commit 013d8f753a
177 changed files with 1657 additions and 2740 deletions

View File

@ -1,28 +1,22 @@
use flowy_user::entities::UserProfile;
use lib_dispatch::prelude::{EventDispatcher, EventResponse, FromBytes, ModuleRequest, StatusCode, ToBytes};
use crate::FlowySDKTest;
use flowy_user::{entities::UserProfile, errors::FlowyError};
use lib_dispatch::prelude::{EventDispatcher, EventResponse, FromBytes, ModuleRequest, StatusCode, ToBytes, *};
use std::{
convert::TryFrom,
fmt::{Debug, Display},
hash::Hash,
marker::PhantomData,
sync::Arc,
};
use crate::FlowySDKTest;
use flowy_core::errors::WorkspaceError;
use flowy_user::errors::UserError;
use lib_dispatch::prelude::*;
use std::{convert::TryFrom, marker::PhantomData, sync::Arc};
pub type CoreModuleEventBuilder = EventBuilder<WorkspaceError>;
pub type CoreModuleEventBuilder = EventBuilder<FlowyError>;
impl CoreModuleEventBuilder {
pub fn new(sdk: FlowySDKTest) -> Self { EventBuilder::test(TestContext::new(sdk)) }
}
pub type UserModuleEventBuilder = EventBuilder<UserError>;
impl UserModuleEventBuilder {
pub fn new(sdk: FlowySDKTest) -> Self { EventBuilder::test(TestContext::new(sdk)) }
pub fn user_profile(&self) -> &Option<UserProfile> { &self.user_profile }
}
pub type UserModuleEventBuilder = CoreModuleEventBuilder;
#[derive(Clone)]
pub struct EventBuilder<E> {
context: TestContext,

View File

@ -13,7 +13,7 @@ use flowy_core::{
};
use flowy_user::{
entities::{SignInRequest, SignUpRequest, UserProfile},
errors::UserError,
errors::FlowyError,
event::UserEvent::{InitUser, SignIn, SignOut, SignUp},
};
use lib_dispatch::prelude::{EventDispatcher, ModuleRequest, ToBytes};
@ -316,7 +316,7 @@ pub fn sign_up(dispatch: Arc<EventDispatcher>) -> SignUpContext {
let request = ModuleRequest::new(SignUp).payload(payload);
let user_profile = EventDispatcher::sync_send(dispatch, request)
.parse::<UserProfile, UserError>()
.parse::<UserProfile, FlowyError>()
.unwrap()
.unwrap();
@ -336,7 +336,7 @@ pub async fn async_sign_up(dispatch: Arc<EventDispatcher>) -> SignUpContext {
let request = ModuleRequest::new(SignUp).payload(payload);
let user_profile = EventDispatcher::async_send(dispatch.clone(), request)
.await
.parse::<UserProfile, UserError>()
.parse::<UserProfile, FlowyError>()
.unwrap()
.unwrap();
@ -361,7 +361,7 @@ fn sign_in(dispatch: Arc<EventDispatcher>) -> UserProfile {
let request = ModuleRequest::new(SignIn).payload(payload);
EventDispatcher::sync_send(dispatch, request)
.parse::<UserProfile, UserError>()
.parse::<UserProfile, FlowyError>()
.unwrap()
.unwrap()
}