Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
generic error builder
appflowy6229b7f5b9eb
diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dartindex 1158167d22..5890b6f76f 100644--- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart+++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart@@ -27,6 +27,7 @@ class UserErrCode extends $pb.ProtobufEnum {static const UserErrCode UserIdInvalid = UserErrCode._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserIdInvalid');static const UserErrCode CreateDefaultWorkspaceFailed = UserErrCode._(25, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CreateDefaultWorkspaceFailed');static const UserErrCode DefaultWorkspaceAlreadyExist = UserErrCode._(26, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DefaultWorkspaceAlreadyExist');+ static const UserErrCode NetworkError = UserErrCode._(100, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'NetworkError');static const $core.List<UserErrCode> values = <UserErrCode> [Unknown,@@ -46,6 +47,7 @@ class UserErrCode extends $pb.ProtobufEnum {UserIdInvalid,CreateDefaultWorkspaceFailed,DefaultWorkspaceAlreadyExist,+ NetworkError,];static final $core.Map<$core.int, UserErrCode> _byValue = $pb.ProtobufEnum.initByValue(values);diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dartindex 09b44306bc..53f0264580 100644--- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart+++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart@@ -29,11 +29,12 @@ const UserErrCode$json = const {const {'1': 'UserIdInvalid', '2': 24},const {'1': 'CreateDefaultWorkspaceFailed', '2': 25},const {'1': 'DefaultWorkspaceAlreadyExist', '2': 26},+ const {'1': 'NetworkError', '2': 100},],};/// Descriptor for `UserErrCode`. Decode as a `google.protobuf.EnumDescriptorProto`.-final $typed_data.Uint8List userErrCodeDescriptor = $convert.base64Decode('CgtVc2VyRXJyQ29kZRILCgdVbmtub3duEAASGgoWVXNlckRhdGFiYXNlSW5pdEZhaWxlZBABEhsKF1VzZXJEYXRhYmFzZVdyaXRlTG9ja2VkEAISGgoWVXNlckRhdGFiYXNlUmVhZExvY2tlZBADEhsKF1VzZXJEYXRhYmFzZURpZE5vdE1hdGNoEAQSHQoZVXNlckRhdGFiYXNlSW50ZXJuYWxFcnJvchAFEhQKEFNxbEludGVybmFsRXJyb3IQBhITCg9Vc2VyTm90TG9naW5ZZXQQChIXChNSZWFkQ3VycmVudElkRmFpbGVkEAsSGAoUV3JpdGVDdXJyZW50SWRGYWlsZWQQDBIQCgxFbWFpbEludmFsaWQQFBITCg9QYXNzd29yZEludmFsaWQQFRITCg9Vc2VyTmFtZUludmFsaWQQFhIYChRVc2VyV29ya3NwYWNlSW52YWxpZBAXEhEKDVVzZXJJZEludmFsaWQQGBIgChxDcmVhdGVEZWZhdWx0V29ya3NwYWNlRmFpbGVkEBkSIAocRGVmYXVsdFdvcmtzcGFjZUFscmVhZHlFeGlzdBAa');+final $typed_data.Uint8List userErrCodeDescriptor = $convert.base64Decode('CgtVc2VyRXJyQ29kZRILCgdVbmtub3duEAASGgoWVXNlckRhdGFiYXNlSW5pdEZhaWxlZBABEhsKF1VzZXJEYXRhYmFzZVdyaXRlTG9ja2VkEAISGgoWVXNlckRhdGFiYXNlUmVhZExvY2tlZBADEhsKF1VzZXJEYXRhYmFzZURpZE5vdE1hdGNoEAQSHQoZVXNlckRhdGFiYXNlSW50ZXJuYWxFcnJvchAFEhQKEFNxbEludGVybmFsRXJyb3IQBhITCg9Vc2VyTm90TG9naW5ZZXQQChIXChNSZWFkQ3VycmVudElkRmFpbGVkEAsSGAoUV3JpdGVDdXJyZW50SWRGYWlsZWQQDBIQCgxFbWFpbEludmFsaWQQFBITCg9QYXNzd29yZEludmFsaWQQFRITCg9Vc2VyTmFtZUludmFsaWQQFhIYChRVc2VyV29ya3NwYWNlSW52YWxpZBAXEhEKDVVzZXJJZEludmFsaWQQGBIgChxDcmVhdGVEZWZhdWx0V29ya3NwYWNlRmFpbGVkEBkSIAocRGVmYXVsdFdvcmtzcGFjZUFscmVhZHlFeGlzdBAaEhAKDE5ldHdvcmtFcnJvchBk');@$core.Deprecated('Use userErrorDescriptor instead')const UserError$json = const {'1': 'UserError',diff --git a/backend/Cargo.toml b/backend/Cargo.tomlindex c8214fc942..859b7849c7 100644--- a/backend/Cargo.toml+++ b/backend/Cargo.toml@@ -25,6 +25,7 @@ serde = { version = "1.0", features = ["derive"] }serde_repr = "0.1"derive_more = {version = "0.99", features = ["display"]}protobuf = {version = "2.20.0"}+uuid = { version = "0.8", features = ["serde", "v4"] }flowy-log = { path = "../rust-lib/flowy-log" }flowy-user = { path = "../rust-lib/flowy-user" }diff --git a/backend/src/user_service/auth.rs b/backend/src/user_service/auth.rsindex 9d560f5f8f..18b983190c 100644--- a/backend/src/user_service/auth.rs+++ b/backend/src/user_service/auth.rs@@ -1,5 +1,5 @@use flowy_net::errors::NetworkError;-use flowy_user::protobuf::SignUpParams;+use flowy_user::{entities::SignUpResponse, protobuf::SignUpParams};use sqlx::PgPool;use std::sync::Arc;@@ -10,5 +10,15 @@ pub struct Auth {impl Auth {pub fn new(db_pool: Arc<PgPool>) -> Self { Self { db_pool } }- pub fn sign_up(&self, params: SignUpParams) -> Result<(), NetworkError> { Ok(()) }+ pub fn sign_up(&self, params: SignUpParams) -> Result<SignUpResponse, NetworkError> {+ // email exist?++ // generate user id++ //++ unimplemented!()+ }++ pub fn is_email_exist(&self, email: &str) -> bool {}}diff --git a/backend/src/user_service/mod.rs b/backend/src/user_service/mod.rsindex ca51de07ab..2a3e687764 100644--- a/backend/src/user_service/mod.rs+++ b/backend/src/user_service/mod.rs@@ -1,3 +1,5 @@mod auth;pub use auth::*;++pub fn uuid() -> String { uuid::Uuid::new_v4().to_string() }diff --git a/rust-lib/dart-ffi/Cargo.toml b/rust-lib/dart-ffi/Cargo.tomlindex b29f4558cf..3132ea54aa 100644--- a/rust-lib/dart-ffi/Cargo.toml+++ b/rust-lib/dart-ffi/Cargo.toml@@ -7,11 +7,11 @@ edition = "2018"[lib]name = "dart_ffi"# this value will change depending on the target os-# for iOS it would be `cdylib`-# for Macos it would be `cdylib`+# for iOS it would be `rlib`+# for Macos it would be `rlib`# for android it would be `c-dylib`-# default cdylib-crate-type = ["cdylib"]+# default rlib+crate-type = ["rlib"][dependencies]diff --git a/rust-lib/dart-ffi/src/model/ffi_request.rs b/rust-lib/dart-ffi/src/model/ffi_request.rsindex 57a53bdd3b..8d3f85720d 100644--- a/rust-lib/dart-ffi/src/model/ffi_request.rs+++ b/rust-lib/dart-ffi/src/model/ffi_request.rs@@ -16,8 +16,7 @@ impl FFIRequest {pub fn from_u8_pointer(pointer: *const u8, len: usize) -> Self {let buffer = unsafe { std::slice::from_raw_parts(pointer, len) }.to_vec();let bytes = Bytes::from(buffer);-- let request: FFIRequest = FFIRequest::try_from(&bytes).unwrap();+ let request: FFIRequest = FFIRequest::try_from(bytes).unwrap();request}}diff --git a/rust-lib/flowy-document/src/errors.rs b/rust-lib/flowy-document/src/errors.rsindex 37cd1ff797..6f682c0f8a 100644--- a/rust-lib/flowy-document/src/errors.rs+++ b/rust-lib/flowy-document/src/errors.rs@@ -80,31 +80,8 @@ impl flowy_dispatch::Error for DocError {}}-pub struct ErrorBuilder {- pub code: DocErrorCode,- pub msg: Option<String>,-}--impl ErrorBuilder {- pub fn new(code: DocErrorCode) -> Self { ErrorBuilder { code, msg: None } }-- pub fn msg<T>(mut self, msg: T) -> Self- where- T: Into<String>,- {- self.msg = Some(msg.into());- self- }-- pub fn error<T>(mut self, msg: T) -> Self- where- T: std::fmt::Debug,- {- self.msg = Some(format!("{:?}", msg));- self- }+pub type ErrorBuilder = flowy_infra::errors::Builder<DocErrorCode, DocError>;- pub fn build(mut self) -> DocError {- DocError::new(self.code, &self.msg.take().unwrap_or("".to_owned()))- }+impl flowy_infra::errors::Build<DocErrorCode> for DocError {+ fn build(code: DocErrorCode, msg: String) -> Self { DocError::new(code, &msg) }}diff --git a/rust-lib/flowy-infra/src/lib.rs b/rust-lib/flowy-infra/src/lib.rsindex f34f10a55d..039494e6d8 100644--- a/rust-lib/flowy-infra/src/lib.rs+++ b/rust-lib/flowy-infra/src/lib.rs@@ -4,6 +4,7 @@ extern crate diesel;#[macro_use]extern crate diesel_derives;+pub mod errors;pub mod kv;mod protobuf;diff --git a/rust-lib/flowy-net/src/errors.rs b/rust-lib/flowy-net/src/errors.rsindex c5d641175b..b419361200 100644--- a/rust-lib/flowy-net/src/errors.rs+++ b/rust-lib/flowy-net/src/errors.rs@@ -5,6 +5,7 @@ use std::fmt::{Formatter, Write};#[derive(Debug)]pub enum NetworkError {InternalError(String),+ ProtobufError(ProtobufError),BadRequest(FlowyResponse<String>),Unauthorized,}@@ -13,6 +14,7 @@ impl std::fmt::Display for NetworkError {fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {match self {NetworkError::InternalError(_) => f.write_str("Internal Server Error"),+ NetworkError::ProtobufError(err) => f.write_str(&format!("protobuf error: {}", err)),NetworkError::BadRequest(request) => {let msg = format!("Bad Request: {:?}", request);f.write_str(&msg)@@ -23,10 +25,7 @@ impl std::fmt::Display for NetworkError {}impl std::convert::From<ProtobufError> for NetworkError {- fn from(err: ProtobufError) -> Self {- let msg = format!("{:?}", err);- NetworkError::InternalError(msg)- }+ fn from(err: ProtobufError) -> Self { NetworkError::ProtobufError(err) }}impl std::convert::From<reqwest::Error> for NetworkError {diff --git a/rust-lib/flowy-net/src/response/response.rs b/rust-lib/flowy-net/src/response/response.rsindex f04878657d..a44709bc0c 100644--- a/rust-lib/flowy-net/src/response/response.rs+++ b/rust-lib/flowy-net/src/response/response.rs@@ -11,6 +11,7 @@ pub enum ServerCode {Unauthorized = 3,PayloadOverflow = 4,PayloadSerdeFail = 5,+ ProtobufError = 6,}#[derive(Debug, Serialize)]diff --git a/rust-lib/flowy-net/src/response/response_http.rs b/rust-lib/flowy-net/src/response/response_http.rsindex 35c270d58d..ecc962384a 100644--- a/rust-lib/flowy-net/src/response/response_http.rs+++ b/rust-lib/flowy-net/src/response/response_http.rs@@ -9,6 +9,10 @@ impl NetworkError {let resp = FlowyResponse::from_msg(&msg, ServerCode::InternalError);HttpResponse::InternalServerError().json(resp)},+ NetworkError::ProtobufError(err) => {+ let resp = FlowyResponse::from_msg(&format!("{}", err), ServerCode::ProtobufError);+ HttpResponse::InternalServerError().json(resp)+ },NetworkError::BadRequest(ref resp) => HttpResponse::BadRequest().json(resp),NetworkError::Unauthorized => {let resp = FlowyResponse::from_msg("Unauthorized", ServerCode::Unauthorized);diff --git a/rust-lib/flowy-user/src/errors.rs b/rust-lib/flowy-user/src/errors.rsindex 7e971721c4..a5883078e3 100644--- a/rust-lib/flowy-user/src/errors.rs+++ b/rust-lib/flowy-user/src/errors.rs@@ -62,6 +62,9 @@ pub enum UserErrCode {#[display(fmt = "User default workspace already exists")]DefaultWorkspaceAlreadyExist = 26,++ #[display(fmt = "Network error")]+ NetworkError = 100,}impl std::default::Default for UserErrCode {@@ -113,6 +116,14 @@ impl std::convert::From<flowy_sqlite::Error> for UserError {}}+impl std::convert::From<flowy_net::errors::NetworkError> for UserError {+ fn from(error: flowy_net::errors::NetworkError) -> Self {+ ErrorBuilder::new(UserErrCode::NetworkError)+ .error(error)+ .build()+ }+}+impl flowy_dispatch::Error for UserError {fn as_response(&self) -> EventResponse {let bytes: Bytes = self.clone().try_into().unwrap();@@ -120,31 +131,8 @@ impl flowy_dispatch::Error for UserError {}}-pub struct ErrorBuilder {- pub code: UserErrCode,- pub msg: Option<String>,-}--impl ErrorBuilder {- pub fn new(code: UserErrCode) -> Self { ErrorBuilder { code, msg: None } }-- pub fn msg<T>(mut self, msg: T) -> Self- where- T: Into<String>,- {- self.msg = Some(msg.into());- self- }+pub type ErrorBuilder = flowy_infra::errors::Builder<UserErrCode, UserError>;- pub fn error<T>(mut self, msg: T) -> Self- where- T: std::fmt::Debug,- {- self.msg = Some(format!("{:?}", msg));- self- }-- pub fn build(mut self) -> UserError {- UserError::new(self.code, &self.msg.take().unwrap_or("".to_owned()))- }+impl flowy_infra::errors::Build<UserErrCode> for UserError {+ fn build(code: UserErrCode, msg: String) -> Self { UserError::new(code, &msg) }}diff --git a/rust-lib/flowy-user/src/protobuf/model/errors.rs b/rust-lib/flowy-user/src/protobuf/model/errors.rsindex ea9b238dde..c59e2d831e 100644--- a/rust-lib/flowy-user/src/protobuf/model/errors.rs+++ b/rust-lib/flowy-user/src/protobuf/model/errors.rs@@ -232,6 +232,7 @@ pub enum UserErrCode {UserIdInvalid = 24,CreateDefaultWorkspaceFailed = 25,DefaultWorkspaceAlreadyExist = 26,+ NetworkError = 100,}impl ::protobuf::ProtobufEnum for UserErrCode {@@ -258,6 +259,7 @@ impl ::protobuf::ProtobufEnum for UserErrCode {24 => ::std::option::Option::Some(UserErrCode::UserIdInvalid),25 => ::std::option::Option::Some(UserErrCode::CreateDefaultWorkspaceFailed),26 => ::std::option::Option::Some(UserErrCode::DefaultWorkspaceAlreadyExist),+ 100 => ::std::option::Option::Some(UserErrCode::NetworkError),_ => ::std::option::Option::None}}@@ -281,6 +283,7 @@ impl ::protobuf::ProtobufEnum for UserErrCode {UserErrCode::UserIdInvalid,UserErrCode::CreateDefaultWorkspaceFailed,UserErrCode::DefaultWorkspaceAlreadyExist,+ UserErrCode::NetworkError,];values}@@ -311,7 +314,7 @@ impl ::protobuf::reflect::ProtobufValue for UserErrCode {static file_descriptor_proto_data: &'static [u8] = b"\\n\x0cerrors.proto\"?\n\tUserError\x12\x20\n\x04code\x18\x01\x20\x01(\\x0e2\x0c.UserErrCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03m\- sg*\xb6\x03\n\x0bUserErrCode\x12\x0b\n\x07Unknown\x10\0\x12\x1a\n\x16Use\+ sg*\xc8\x03\n\x0bUserErrCode\x12\x0b\n\x07Unknown\x10\0\x12\x1a\n\x16Use\rDatabaseInitFailed\x10\x01\x12\x1b\n\x17UserDatabaseWriteLocked\x10\x02\\x12\x1a\n\x16UserDatabaseReadLocked\x10\x03\x12\x1b\n\x17UserDatabaseDi\dNotMatch\x10\x04\x12\x1d\n\x19UserDatabaseInternalError\x10\x05\x12\x14\@@ -321,49 +324,52 @@ static file_descriptor_proto_data: &'static [u8] = b"\\x10\x15\x12\x13\n\x0fUserNameInvalid\x10\x16\x12\x18\n\x14UserWorkspace\Invalid\x10\x17\x12\x11\n\rUserIdInvalid\x10\x18\x12\x20\n\x1cCreateDefa\ultWorkspaceFailed\x10\x19\x12\x20\n\x1cDefaultWorkspaceAlreadyExist\x10\- \x1aJ\xe9\x06\n\x06\x12\x04\0\0\x18\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\- \n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\- \x08\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x19\n\x0c\n\x05\x04\0\- \x02\0\x06\x12\x03\x03\x04\x0f\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\- \x10\x14\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x17\x18\n\x0b\n\x04\x04\- \0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\- \x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0e\n\x0c\n\x05\x04\- \0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\0\x12\x04\x06\0\x18\x01\- \n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x10\n\x0b\n\x04\x05\0\x02\0\x12\x03\- \x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\x04\x0b\n\x0c\n\x05\- \x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\- \x08\x04\x1f\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\x04\x1a\n\x0c\n\- \x05\x05\0\x02\x01\x02\x12\x03\x08\x1d\x1e\n\x0b\n\x04\x05\0\x02\x02\x12\- \x03\t\x04\x20\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\x04\x1b\n\x0c\n\- \x05\x05\0\x02\x02\x02\x12\x03\t\x1e\x1f\n\x0b\n\x04\x05\0\x02\x03\x12\- \x03\n\x04\x1f\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\x1a\n\x0c\n\- \x05\x05\0\x02\x03\x02\x12\x03\n\x1d\x1e\n\x0b\n\x04\x05\0\x02\x04\x12\- \x03\x0b\x04\x20\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\x04\x1b\n\x0c\- \n\x05\x05\0\x02\x04\x02\x12\x03\x0b\x1e\x1f\n\x0b\n\x04\x05\0\x02\x05\- \x12\x03\x0c\x04\"\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x0c\x04\x1d\n\- \x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x0c\x20!\n\x0b\n\x04\x05\0\x02\x06\- \x12\x03\r\x04\x19\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x14\n\x0c\- \n\x05\x05\0\x02\x06\x02\x12\x03\r\x17\x18\n\x0b\n\x04\x05\0\x02\x07\x12\- \x03\x0e\x04\x19\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x13\n\x0c\- \n\x05\x05\0\x02\x07\x02\x12\x03\x0e\x16\x18\n\x0b\n\x04\x05\0\x02\x08\- \x12\x03\x0f\x04\x1d\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\x17\n\- \x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0f\x1a\x1c\n\x0b\n\x04\x05\0\x02\t\- \x12\x03\x10\x04\x1e\n\x0c\n\x05\x05\0\x02\t\x01\x12\x03\x10\x04\x18\n\- \x0c\n\x05\x05\0\x02\t\x02\x12\x03\x10\x1b\x1d\n\x0b\n\x04\x05\0\x02\n\- \x12\x03\x11\x04\x16\n\x0c\n\x05\x05\0\x02\n\x01\x12\x03\x11\x04\x10\n\- \x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\x13\x15\n\x0b\n\x04\x05\0\x02\x0b\- \x12\x03\x12\x04\x19\n\x0c\n\x05\x05\0\x02\x0b\x01\x12\x03\x12\x04\x13\n\- \x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x12\x16\x18\n\x0b\n\x04\x05\0\x02\- \x0c\x12\x03\x13\x04\x19\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\x03\x13\x04\- \x13\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x13\x16\x18\n\x0b\n\x04\x05\0\- \x02\r\x12\x03\x14\x04\x1e\n\x0c\n\x05\x05\0\x02\r\x01\x12\x03\x14\x04\- \x18\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x14\x1b\x1d\n\x0b\n\x04\x05\0\- \x02\x0e\x12\x03\x15\x04\x17\n\x0c\n\x05\x05\0\x02\x0e\x01\x12\x03\x15\- \x04\x11\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\x15\x14\x16\n\x0b\n\x04\- \x05\0\x02\x0f\x12\x03\x16\x04&\n\x0c\n\x05\x05\0\x02\x0f\x01\x12\x03\- \x16\x04\x20\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\x03\x16#%\n\x0b\n\x04\x05\- \0\x02\x10\x12\x03\x17\x04&\n\x0c\n\x05\x05\0\x02\x10\x01\x12\x03\x17\- \x04\x20\n\x0c\n\x05\x05\0\x02\x10\x02\x12\x03\x17#%b\x06proto3\+ \x1a\x12\x10\n\x0cNetworkError\x10dJ\x92\x07\n\x06\x12\x04\0\0\x19\x01\n\+ \x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\+ \n\x03\x04\0\x01\x12\x03\x02\x08\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\+ \x04\x19\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x03\x04\x0f\n\x0c\n\x05\x04\+ \0\x02\0\x01\x12\x03\x03\x10\x14\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\+ \x17\x18\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\+ \x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\+ \x0b\x0e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\+ \0\x12\x04\x06\0\x19\x01\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x10\n\x0b\n\+ \x04\x05\0\x02\0\x12\x03\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\+ \x07\x04\x0b\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\+ \x05\0\x02\x01\x12\x03\x08\x04\x1f\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\+ \x08\x04\x1a\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x1d\x1e\n\x0b\n\+ \x04\x05\0\x02\x02\x12\x03\t\x04\x20\n\x0c\n\x05\x05\0\x02\x02\x01\x12\+ \x03\t\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x1e\x1f\n\x0b\n\+ \x04\x05\0\x02\x03\x12\x03\n\x04\x1f\n\x0c\n\x05\x05\0\x02\x03\x01\x12\+ \x03\n\x04\x1a\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\n\x1d\x1e\n\x0b\n\+ \x04\x05\0\x02\x04\x12\x03\x0b\x04\x20\n\x0c\n\x05\x05\0\x02\x04\x01\x12\+ \x03\x0b\x04\x1b\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\x1e\x1f\n\x0b\+ \n\x04\x05\0\x02\x05\x12\x03\x0c\x04\"\n\x0c\n\x05\x05\0\x02\x05\x01\x12\+ \x03\x0c\x04\x1d\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x0c\x20!\n\x0b\n\+ \x04\x05\0\x02\x06\x12\x03\r\x04\x19\n\x0c\n\x05\x05\0\x02\x06\x01\x12\+ \x03\r\x04\x14\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\r\x17\x18\n\x0b\n\+ \x04\x05\0\x02\x07\x12\x03\x0e\x04\x19\n\x0c\n\x05\x05\0\x02\x07\x01\x12\+ \x03\x0e\x04\x13\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\x0e\x16\x18\n\x0b\+ \n\x04\x05\0\x02\x08\x12\x03\x0f\x04\x1d\n\x0c\n\x05\x05\0\x02\x08\x01\+ \x12\x03\x0f\x04\x17\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0f\x1a\x1c\n\+ \x0b\n\x04\x05\0\x02\t\x12\x03\x10\x04\x1e\n\x0c\n\x05\x05\0\x02\t\x01\+ \x12\x03\x10\x04\x18\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x10\x1b\x1d\n\+ \x0b\n\x04\x05\0\x02\n\x12\x03\x11\x04\x16\n\x0c\n\x05\x05\0\x02\n\x01\+ \x12\x03\x11\x04\x10\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\x13\x15\n\+ \x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04\x19\n\x0c\n\x05\x05\0\x02\x0b\+ \x01\x12\x03\x12\x04\x13\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x12\x16\+ \x18\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x13\x04\x19\n\x0c\n\x05\x05\0\x02\+ \x0c\x01\x12\x03\x13\x04\x13\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x13\+ \x16\x18\n\x0b\n\x04\x05\0\x02\r\x12\x03\x14\x04\x1e\n\x0c\n\x05\x05\0\+ \x02\r\x01\x12\x03\x14\x04\x18\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x14\+ \x1b\x1d\n\x0b\n\x04\x05\0\x02\x0e\x12\x03\x15\x04\x17\n\x0c\n\x05\x05\0\+ \x02\x0e\x01\x12\x03\x15\x04\x11\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\+ \x15\x14\x16\n\x0b\n\x04\x05\0\x02\x0f\x12\x03\x16\x04&\n\x0c\n\x05\x05\+ \0\x02\x0f\x01\x12\x03\x16\x04\x20\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\x03\+ \x16#%\n\x0b\n\x04\x05\0\x02\x10\x12\x03\x17\x04&\n\x0c\n\x05\x05\0\x02\+ \x10\x01\x12\x03\x17\x04\x20\n\x0c\n\x05\x05\0\x02\x10\x02\x12\x03\x17#%\+ \n\x0b\n\x04\x05\0\x02\x11\x12\x03\x18\x04\x17\n\x0c\n\x05\x05\0\x02\x11\+ \x01\x12\x03\x18\x04\x10\n\x0c\n\x05\x05\0\x02\x11\x02\x12\x03\x18\x13\+ \x16b\x06proto3\";static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;diff --git a/rust-lib/flowy-user/src/protobuf/proto/errors.proto b/rust-lib/flowy-user/src/protobuf/proto/errors.protoindex 9a35970949..2b2cc7b4b9 100644--- a/rust-lib/flowy-user/src/protobuf/proto/errors.proto+++ b/rust-lib/flowy-user/src/protobuf/proto/errors.proto@@ -22,4 +22,5 @@ enum UserErrCode {UserIdInvalid = 24;CreateDefaultWorkspaceFailed = 25;DefaultWorkspaceAlreadyExist = 26;+ NetworkError = 100;}diff --git a/rust-lib/flowy-user/src/services/user/user_server.rs b/rust-lib/flowy-user/src/services/user/user_server.rsindex 446b19ee73..98cdafd04d 100644--- a/rust-lib/flowy-user/src/services/user/user_server.rs+++ b/rust-lib/flowy-user/src/services/user/user_server.rs@@ -28,8 +28,8 @@ impl UserServerImpl {}impl UserServer for UserServerImpl {fn sign_up(&self, params: SignUpParams) -> ResultFuture<SignUpResponse, UserError> {ResultFuture::new(async move {- let a = http_post(SIGN_UP_URL.as_ref(), params).await?;- Ok(a)+ let resp = http_post(SIGN_UP_URL.as_ref(), params).await?;+ Ok(resp)})}diff --git a/rust-lib/flowy-workspace/src/errors.rs b/rust-lib/flowy-workspace/src/errors.rsindex c7560d364d..a164faa984 100644--- a/rust-lib/flowy-workspace/src/errors.rs+++ b/rust-lib/flowy-workspace/src/errors.rs@@ -86,31 +86,8 @@ impl flowy_dispatch::Error for WorkspaceError {}}-pub struct ErrorBuilder {- pub code: WsErrCode,- pub msg: Option<String>,-}--impl ErrorBuilder {- pub fn new(code: WsErrCode) -> Self { ErrorBuilder { code, msg: None } }-- pub fn msg<T>(mut self, msg: T) -> Self- where- T: Into<String>,- {- self.msg = Some(msg.into());- self- }-- pub fn error<T>(mut self, msg: T) -> Self- where- T: std::fmt::Debug,- {- self.msg = Some(format!("{:?}", msg));- self- }+pub type ErrorBuilder = flowy_infra::errors::Builder<WsErrCode, WorkspaceError>;- pub fn build(mut self) -> WorkspaceError {- WorkspaceError::new(self.code, &self.msg.take().unwrap_or("".to_owned()))- }+impl flowy_infra::errors::Build<WsErrCode> for WorkspaceError {+ fn build(code: WsErrCode, msg: String) -> Self { WorkspaceError::new(code, &msg) }}