mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
generic error builder
This commit is contained in:
parent
57b4a8e114
commit
6229b7f5b9
@ -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 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 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 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> [
|
static const $core.List<UserErrCode> values = <UserErrCode> [
|
||||||
Unknown,
|
Unknown,
|
||||||
@ -46,6 +47,7 @@ class UserErrCode extends $pb.ProtobufEnum {
|
|||||||
UserIdInvalid,
|
UserIdInvalid,
|
||||||
CreateDefaultWorkspaceFailed,
|
CreateDefaultWorkspaceFailed,
|
||||||
DefaultWorkspaceAlreadyExist,
|
DefaultWorkspaceAlreadyExist,
|
||||||
|
NetworkError,
|
||||||
];
|
];
|
||||||
|
|
||||||
static final $core.Map<$core.int, UserErrCode> _byValue = $pb.ProtobufEnum.initByValue(values);
|
static final $core.Map<$core.int, UserErrCode> _byValue = $pb.ProtobufEnum.initByValue(values);
|
||||||
|
@ -29,11 +29,12 @@ const UserErrCode$json = const {
|
|||||||
const {'1': 'UserIdInvalid', '2': 24},
|
const {'1': 'UserIdInvalid', '2': 24},
|
||||||
const {'1': 'CreateDefaultWorkspaceFailed', '2': 25},
|
const {'1': 'CreateDefaultWorkspaceFailed', '2': 25},
|
||||||
const {'1': 'DefaultWorkspaceAlreadyExist', '2': 26},
|
const {'1': 'DefaultWorkspaceAlreadyExist', '2': 26},
|
||||||
|
const {'1': 'NetworkError', '2': 100},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Descriptor for `UserErrCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
|
/// 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')
|
@$core.Deprecated('Use userErrorDescriptor instead')
|
||||||
const UserError$json = const {
|
const UserError$json = const {
|
||||||
'1': 'UserError',
|
'1': 'UserError',
|
||||||
|
@ -25,6 +25,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
serde_repr = "0.1"
|
serde_repr = "0.1"
|
||||||
derive_more = {version = "0.99", features = ["display"]}
|
derive_more = {version = "0.99", features = ["display"]}
|
||||||
protobuf = {version = "2.20.0"}
|
protobuf = {version = "2.20.0"}
|
||||||
|
uuid = { version = "0.8", features = ["serde", "v4"] }
|
||||||
|
|
||||||
flowy-log = { path = "../rust-lib/flowy-log" }
|
flowy-log = { path = "../rust-lib/flowy-log" }
|
||||||
flowy-user = { path = "../rust-lib/flowy-user" }
|
flowy-user = { path = "../rust-lib/flowy-user" }
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use flowy_net::errors::NetworkError;
|
use flowy_net::errors::NetworkError;
|
||||||
use flowy_user::protobuf::SignUpParams;
|
use flowy_user::{entities::SignUpResponse, protobuf::SignUpParams};
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@ -10,5 +10,15 @@ pub struct Auth {
|
|||||||
impl Auth {
|
impl Auth {
|
||||||
pub fn new(db_pool: Arc<PgPool>) -> Self { Self { db_pool } }
|
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 {}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
mod auth;
|
mod auth;
|
||||||
|
|
||||||
pub use auth::*;
|
pub use auth::*;
|
||||||
|
|
||||||
|
pub fn uuid() -> String { uuid::Uuid::new_v4().to_string() }
|
||||||
|
@ -7,11 +7,11 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
name = "dart_ffi"
|
name = "dart_ffi"
|
||||||
# this value will change depending on the target os
|
# this value will change depending on the target os
|
||||||
# for iOS it would be `cdylib`
|
# for iOS it would be `rlib`
|
||||||
# for Macos it would be `cdylib`
|
# for Macos it would be `rlib`
|
||||||
# for android it would be `c-dylib`
|
# for android it would be `c-dylib`
|
||||||
# default cdylib
|
# default rlib
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["rlib"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -16,8 +16,7 @@ impl FFIRequest {
|
|||||||
pub fn from_u8_pointer(pointer: *const u8, len: usize) -> Self {
|
pub fn from_u8_pointer(pointer: *const u8, len: usize) -> Self {
|
||||||
let buffer = unsafe { std::slice::from_raw_parts(pointer, len) }.to_vec();
|
let buffer = unsafe { std::slice::from_raw_parts(pointer, len) }.to_vec();
|
||||||
let bytes = Bytes::from(buffer);
|
let bytes = Bytes::from(buffer);
|
||||||
|
let request: FFIRequest = FFIRequest::try_from(bytes).unwrap();
|
||||||
let request: FFIRequest = FFIRequest::try_from(&bytes).unwrap();
|
|
||||||
request
|
request
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,31 +80,8 @@ impl flowy_dispatch::Error for DocError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ErrorBuilder {
|
pub type ErrorBuilder = flowy_infra::errors::Builder<DocErrorCode, DocError>;
|
||||||
pub code: DocErrorCode,
|
|
||||||
pub msg: Option<String>,
|
impl flowy_infra::errors::Build<DocErrorCode> for DocError {
|
||||||
}
|
fn build(code: DocErrorCode, msg: String) -> Self { DocError::new(code, &msg) }
|
||||||
|
|
||||||
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 fn build(mut self) -> DocError {
|
|
||||||
DocError::new(self.code, &self.msg.take().unwrap_or("".to_owned()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ extern crate diesel;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate diesel_derives;
|
extern crate diesel_derives;
|
||||||
|
|
||||||
|
pub mod errors;
|
||||||
pub mod kv;
|
pub mod kv;
|
||||||
mod protobuf;
|
mod protobuf;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ use std::fmt::{Formatter, Write};
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum NetworkError {
|
pub enum NetworkError {
|
||||||
InternalError(String),
|
InternalError(String),
|
||||||
|
ProtobufError(ProtobufError),
|
||||||
BadRequest(FlowyResponse<String>),
|
BadRequest(FlowyResponse<String>),
|
||||||
Unauthorized,
|
Unauthorized,
|
||||||
}
|
}
|
||||||
@ -13,6 +14,7 @@ impl std::fmt::Display for NetworkError {
|
|||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
NetworkError::InternalError(_) => f.write_str("Internal Server Error"),
|
NetworkError::InternalError(_) => f.write_str("Internal Server Error"),
|
||||||
|
NetworkError::ProtobufError(err) => f.write_str(&format!("protobuf error: {}", err)),
|
||||||
NetworkError::BadRequest(request) => {
|
NetworkError::BadRequest(request) => {
|
||||||
let msg = format!("Bad Request: {:?}", request);
|
let msg = format!("Bad Request: {:?}", request);
|
||||||
f.write_str(&msg)
|
f.write_str(&msg)
|
||||||
@ -23,10 +25,7 @@ impl std::fmt::Display for NetworkError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<ProtobufError> for NetworkError {
|
impl std::convert::From<ProtobufError> for NetworkError {
|
||||||
fn from(err: ProtobufError) -> Self {
|
fn from(err: ProtobufError) -> Self { NetworkError::ProtobufError(err) }
|
||||||
let msg = format!("{:?}", err);
|
|
||||||
NetworkError::InternalError(msg)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<reqwest::Error> for NetworkError {
|
impl std::convert::From<reqwest::Error> for NetworkError {
|
||||||
|
@ -11,6 +11,7 @@ pub enum ServerCode {
|
|||||||
Unauthorized = 3,
|
Unauthorized = 3,
|
||||||
PayloadOverflow = 4,
|
PayloadOverflow = 4,
|
||||||
PayloadSerdeFail = 5,
|
PayloadSerdeFail = 5,
|
||||||
|
ProtobufError = 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
@ -9,6 +9,10 @@ impl NetworkError {
|
|||||||
let resp = FlowyResponse::from_msg(&msg, ServerCode::InternalError);
|
let resp = FlowyResponse::from_msg(&msg, ServerCode::InternalError);
|
||||||
HttpResponse::InternalServerError().json(resp)
|
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::BadRequest(ref resp) => HttpResponse::BadRequest().json(resp),
|
||||||
NetworkError::Unauthorized => {
|
NetworkError::Unauthorized => {
|
||||||
let resp = FlowyResponse::from_msg("Unauthorized", ServerCode::Unauthorized);
|
let resp = FlowyResponse::from_msg("Unauthorized", ServerCode::Unauthorized);
|
||||||
|
@ -62,6 +62,9 @@ pub enum UserErrCode {
|
|||||||
|
|
||||||
#[display(fmt = "User default workspace already exists")]
|
#[display(fmt = "User default workspace already exists")]
|
||||||
DefaultWorkspaceAlreadyExist = 26,
|
DefaultWorkspaceAlreadyExist = 26,
|
||||||
|
|
||||||
|
#[display(fmt = "Network error")]
|
||||||
|
NetworkError = 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::default::Default for UserErrCode {
|
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 {
|
impl flowy_dispatch::Error for UserError {
|
||||||
fn as_response(&self) -> EventResponse {
|
fn as_response(&self) -> EventResponse {
|
||||||
let bytes: Bytes = self.clone().try_into().unwrap();
|
let bytes: Bytes = self.clone().try_into().unwrap();
|
||||||
@ -120,31 +131,8 @@ impl flowy_dispatch::Error for UserError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ErrorBuilder {
|
pub type ErrorBuilder = flowy_infra::errors::Builder<UserErrCode, UserError>;
|
||||||
pub code: UserErrCode,
|
|
||||||
pub msg: Option<String>,
|
impl flowy_infra::errors::Build<UserErrCode> for UserError {
|
||||||
}
|
fn build(code: UserErrCode, msg: String) -> Self { UserError::new(code, &msg) }
|
||||||
|
|
||||||
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 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()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -232,6 +232,7 @@ pub enum UserErrCode {
|
|||||||
UserIdInvalid = 24,
|
UserIdInvalid = 24,
|
||||||
CreateDefaultWorkspaceFailed = 25,
|
CreateDefaultWorkspaceFailed = 25,
|
||||||
DefaultWorkspaceAlreadyExist = 26,
|
DefaultWorkspaceAlreadyExist = 26,
|
||||||
|
NetworkError = 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::protobuf::ProtobufEnum for UserErrCode {
|
impl ::protobuf::ProtobufEnum for UserErrCode {
|
||||||
@ -258,6 +259,7 @@ impl ::protobuf::ProtobufEnum for UserErrCode {
|
|||||||
24 => ::std::option::Option::Some(UserErrCode::UserIdInvalid),
|
24 => ::std::option::Option::Some(UserErrCode::UserIdInvalid),
|
||||||
25 => ::std::option::Option::Some(UserErrCode::CreateDefaultWorkspaceFailed),
|
25 => ::std::option::Option::Some(UserErrCode::CreateDefaultWorkspaceFailed),
|
||||||
26 => ::std::option::Option::Some(UserErrCode::DefaultWorkspaceAlreadyExist),
|
26 => ::std::option::Option::Some(UserErrCode::DefaultWorkspaceAlreadyExist),
|
||||||
|
100 => ::std::option::Option::Some(UserErrCode::NetworkError),
|
||||||
_ => ::std::option::Option::None
|
_ => ::std::option::Option::None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,6 +283,7 @@ impl ::protobuf::ProtobufEnum for UserErrCode {
|
|||||||
UserErrCode::UserIdInvalid,
|
UserErrCode::UserIdInvalid,
|
||||||
UserErrCode::CreateDefaultWorkspaceFailed,
|
UserErrCode::CreateDefaultWorkspaceFailed,
|
||||||
UserErrCode::DefaultWorkspaceAlreadyExist,
|
UserErrCode::DefaultWorkspaceAlreadyExist,
|
||||||
|
UserErrCode::NetworkError,
|
||||||
];
|
];
|
||||||
values
|
values
|
||||||
}
|
}
|
||||||
@ -311,7 +314,7 @@ impl ::protobuf::reflect::ProtobufValue for UserErrCode {
|
|||||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||||
\n\x0cerrors.proto\"?\n\tUserError\x12\x20\n\x04code\x18\x01\x20\x01(\
|
\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\
|
\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\
|
rDatabaseInitFailed\x10\x01\x12\x1b\n\x17UserDatabaseWriteLocked\x10\x02\
|
||||||
\x12\x1a\n\x16UserDatabaseReadLocked\x10\x03\x12\x1b\n\x17UserDatabaseDi\
|
\x12\x1a\n\x16UserDatabaseReadLocked\x10\x03\x12\x1b\n\x17UserDatabaseDi\
|
||||||
dNotMatch\x10\x04\x12\x1d\n\x19UserDatabaseInternalError\x10\x05\x12\x14\
|
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\
|
\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\
|
Invalid\x10\x17\x12\x11\n\rUserIdInvalid\x10\x18\x12\x20\n\x1cCreateDefa\
|
||||||
ultWorkspaceFailed\x10\x19\x12\x20\n\x1cDefaultWorkspaceAlreadyExist\x10\
|
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\
|
\x1a\x12\x10\n\x0cNetworkError\x10dJ\x92\x07\n\x06\x12\x04\0\0\x19\x01\n\
|
||||||
\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\
|
\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\
|
||||||
\x08\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x19\n\x0c\n\x05\x04\0\
|
\n\x03\x04\0\x01\x12\x03\x02\x08\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\
|
||||||
\x02\0\x06\x12\x03\x03\x04\x0f\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\
|
\x04\x19\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x03\x04\x0f\n\x0c\n\x05\x04\
|
||||||
\x10\x14\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x17\x18\n\x0b\n\x04\x04\
|
\0\x02\0\x01\x12\x03\x03\x10\x14\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\
|
||||||
\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\
|
\x17\x18\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\
|
||||||
\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0e\n\x0c\n\x05\x04\
|
\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\
|
||||||
\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\0\x12\x04\x06\0\x18\x01\
|
\x0b\x0e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\
|
||||||
\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x10\n\x0b\n\x04\x05\0\x02\0\x12\x03\
|
\0\x12\x04\x06\0\x19\x01\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x10\n\x0b\n\
|
||||||
\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\x04\x0b\n\x0c\n\x05\
|
\x04\x05\0\x02\0\x12\x03\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\
|
||||||
\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\
|
\x07\x04\x0b\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\
|
||||||
\x08\x04\x1f\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\x04\x1a\n\x0c\n\
|
\x05\0\x02\x01\x12\x03\x08\x04\x1f\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\
|
||||||
\x05\x05\0\x02\x01\x02\x12\x03\x08\x1d\x1e\n\x0b\n\x04\x05\0\x02\x02\x12\
|
\x08\x04\x1a\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x1d\x1e\n\x0b\n\
|
||||||
\x03\t\x04\x20\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\x04\x1b\n\x0c\n\
|
\x04\x05\0\x02\x02\x12\x03\t\x04\x20\n\x0c\n\x05\x05\0\x02\x02\x01\x12\
|
||||||
\x05\x05\0\x02\x02\x02\x12\x03\t\x1e\x1f\n\x0b\n\x04\x05\0\x02\x03\x12\
|
\x03\t\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x1e\x1f\n\x0b\n\
|
||||||
\x03\n\x04\x1f\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\x1a\n\x0c\n\
|
\x04\x05\0\x02\x03\x12\x03\n\x04\x1f\n\x0c\n\x05\x05\0\x02\x03\x01\x12\
|
||||||
\x05\x05\0\x02\x03\x02\x12\x03\n\x1d\x1e\n\x0b\n\x04\x05\0\x02\x04\x12\
|
\x03\n\x04\x1a\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\n\x1d\x1e\n\x0b\n\
|
||||||
\x03\x0b\x04\x20\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\x04\x1b\n\x0c\
|
\x04\x05\0\x02\x04\x12\x03\x0b\x04\x20\n\x0c\n\x05\x05\0\x02\x04\x01\x12\
|
||||||
\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\x1e\x1f\n\x0b\n\x04\x05\0\x02\x05\
|
\x03\x0b\x04\x1b\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\x1e\x1f\n\x0b\
|
||||||
\x12\x03\x0c\x04\"\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x0c\x04\x1d\n\
|
\n\x04\x05\0\x02\x05\x12\x03\x0c\x04\"\n\x0c\n\x05\x05\0\x02\x05\x01\x12\
|
||||||
\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x0c\x20!\n\x0b\n\x04\x05\0\x02\x06\
|
\x03\x0c\x04\x1d\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x0c\x20!\n\x0b\n\
|
||||||
\x12\x03\r\x04\x19\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x14\n\x0c\
|
\x04\x05\0\x02\x06\x12\x03\r\x04\x19\n\x0c\n\x05\x05\0\x02\x06\x01\x12\
|
||||||
\n\x05\x05\0\x02\x06\x02\x12\x03\r\x17\x18\n\x0b\n\x04\x05\0\x02\x07\x12\
|
\x03\r\x04\x14\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\r\x17\x18\n\x0b\n\
|
||||||
\x03\x0e\x04\x19\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x13\n\x0c\
|
\x04\x05\0\x02\x07\x12\x03\x0e\x04\x19\n\x0c\n\x05\x05\0\x02\x07\x01\x12\
|
||||||
\n\x05\x05\0\x02\x07\x02\x12\x03\x0e\x16\x18\n\x0b\n\x04\x05\0\x02\x08\
|
\x03\x0e\x04\x13\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\x0e\x16\x18\n\x0b\
|
||||||
\x12\x03\x0f\x04\x1d\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\x17\n\
|
\n\x04\x05\0\x02\x08\x12\x03\x0f\x04\x1d\n\x0c\n\x05\x05\0\x02\x08\x01\
|
||||||
\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0f\x1a\x1c\n\x0b\n\x04\x05\0\x02\t\
|
\x12\x03\x0f\x04\x17\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0f\x1a\x1c\n\
|
||||||
\x12\x03\x10\x04\x1e\n\x0c\n\x05\x05\0\x02\t\x01\x12\x03\x10\x04\x18\n\
|
\x0b\n\x04\x05\0\x02\t\x12\x03\x10\x04\x1e\n\x0c\n\x05\x05\0\x02\t\x01\
|
||||||
\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x10\x1b\x1d\n\x0b\n\x04\x05\0\x02\n\
|
\x12\x03\x10\x04\x18\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x10\x1b\x1d\n\
|
||||||
\x12\x03\x11\x04\x16\n\x0c\n\x05\x05\0\x02\n\x01\x12\x03\x11\x04\x10\n\
|
\x0b\n\x04\x05\0\x02\n\x12\x03\x11\x04\x16\n\x0c\n\x05\x05\0\x02\n\x01\
|
||||||
\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\x13\x15\n\x0b\n\x04\x05\0\x02\x0b\
|
\x12\x03\x11\x04\x10\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\x13\x15\n\
|
||||||
\x12\x03\x12\x04\x19\n\x0c\n\x05\x05\0\x02\x0b\x01\x12\x03\x12\x04\x13\n\
|
\x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04\x19\n\x0c\n\x05\x05\0\x02\x0b\
|
||||||
\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x12\x16\x18\n\x0b\n\x04\x05\0\x02\
|
\x01\x12\x03\x12\x04\x13\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x12\x16\
|
||||||
\x0c\x12\x03\x13\x04\x19\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\x03\x13\x04\
|
\x18\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x13\x04\x19\n\x0c\n\x05\x05\0\x02\
|
||||||
\x13\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x13\x16\x18\n\x0b\n\x04\x05\0\
|
\x0c\x01\x12\x03\x13\x04\x13\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x13\
|
||||||
\x02\r\x12\x03\x14\x04\x1e\n\x0c\n\x05\x05\0\x02\r\x01\x12\x03\x14\x04\
|
\x16\x18\n\x0b\n\x04\x05\0\x02\r\x12\x03\x14\x04\x1e\n\x0c\n\x05\x05\0\
|
||||||
\x18\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x14\x1b\x1d\n\x0b\n\x04\x05\0\
|
\x02\r\x01\x12\x03\x14\x04\x18\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x14\
|
||||||
\x02\x0e\x12\x03\x15\x04\x17\n\x0c\n\x05\x05\0\x02\x0e\x01\x12\x03\x15\
|
\x1b\x1d\n\x0b\n\x04\x05\0\x02\x0e\x12\x03\x15\x04\x17\n\x0c\n\x05\x05\0\
|
||||||
\x04\x11\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\x15\x14\x16\n\x0b\n\x04\
|
\x02\x0e\x01\x12\x03\x15\x04\x11\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\
|
||||||
\x05\0\x02\x0f\x12\x03\x16\x04&\n\x0c\n\x05\x05\0\x02\x0f\x01\x12\x03\
|
\x15\x14\x16\n\x0b\n\x04\x05\0\x02\x0f\x12\x03\x16\x04&\n\x0c\n\x05\x05\
|
||||||
\x16\x04\x20\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\x03\x16#%\n\x0b\n\x04\x05\
|
\0\x02\x0f\x01\x12\x03\x16\x04\x20\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\x03\
|
||||||
\0\x02\x10\x12\x03\x17\x04&\n\x0c\n\x05\x05\0\x02\x10\x01\x12\x03\x17\
|
\x16#%\n\x0b\n\x04\x05\0\x02\x10\x12\x03\x17\x04&\n\x0c\n\x05\x05\0\x02\
|
||||||
\x04\x20\n\x0c\n\x05\x05\0\x02\x10\x02\x12\x03\x17#%b\x06proto3\
|
\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;
|
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||||
|
@ -22,4 +22,5 @@ enum UserErrCode {
|
|||||||
UserIdInvalid = 24;
|
UserIdInvalid = 24;
|
||||||
CreateDefaultWorkspaceFailed = 25;
|
CreateDefaultWorkspaceFailed = 25;
|
||||||
DefaultWorkspaceAlreadyExist = 26;
|
DefaultWorkspaceAlreadyExist = 26;
|
||||||
|
NetworkError = 100;
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ impl UserServerImpl {}
|
|||||||
impl UserServer for UserServerImpl {
|
impl UserServer for UserServerImpl {
|
||||||
fn sign_up(&self, params: SignUpParams) -> ResultFuture<SignUpResponse, UserError> {
|
fn sign_up(&self, params: SignUpParams) -> ResultFuture<SignUpResponse, UserError> {
|
||||||
ResultFuture::new(async move {
|
ResultFuture::new(async move {
|
||||||
let a = http_post(SIGN_UP_URL.as_ref(), params).await?;
|
let resp = http_post(SIGN_UP_URL.as_ref(), params).await?;
|
||||||
Ok(a)
|
Ok(resp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,31 +86,8 @@ impl flowy_dispatch::Error for WorkspaceError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ErrorBuilder {
|
pub type ErrorBuilder = flowy_infra::errors::Builder<WsErrCode, WorkspaceError>;
|
||||||
pub code: WsErrCode,
|
|
||||||
pub msg: Option<String>,
|
impl flowy_infra::errors::Build<WsErrCode> for WorkspaceError {
|
||||||
}
|
fn build(code: WsErrCode, msg: String) -> Self { WorkspaceError::new(code, &msg) }
|
||||||
|
|
||||||
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 fn build(mut self) -> WorkspaceError {
|
|
||||||
WorkspaceError::new(self.code, &self.msg.take().unwrap_or("".to_owned()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user