mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
refactor errors
This commit is contained in:
@ -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,
|
||||
|
@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user