chore: print duplicate event erorr

This commit is contained in:
appflowy 2022-04-27 07:58:40 +08:00
parent e8bb6f0a7f
commit b29f53c995
11 changed files with 35 additions and 24 deletions

View File

@ -73,6 +73,6 @@ class AppService {
..to = toIndex
..ty = MoveFolderItemType.MoveView;
return FolderEventMoveItem(payload).send();
return FolderEventMoveFolderItem(payload).send();
}
}

View File

@ -62,6 +62,6 @@ class WorkspaceService {
..to = toIndex
..ty = MoveFolderItemType.MoveApp;
return FolderEventMoveItem(payload).send();
return FolderEventMoveFolderItem(payload).send();
}
}

View File

@ -301,13 +301,13 @@ class FolderEventCloseView {
}
}
class FolderEventMoveItem {
class FolderEventMoveFolderItem {
MoveFolderItemPayload request;
FolderEventMoveItem(this.request);
FolderEventMoveFolderItem(this.request);
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = FolderEvent.MoveItem.toString()
..event = FolderEvent.MoveFolderItem.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)

View File

@ -28,7 +28,7 @@ class FolderEvent extends $pb.ProtobufEnum {
static const FolderEvent CopyLink = FolderEvent._(206, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CopyLink');
static const FolderEvent SetLatestView = FolderEvent._(207, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SetLatestView');
static const FolderEvent CloseView = FolderEvent._(208, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CloseView');
static const FolderEvent MoveItem = FolderEvent._(209, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'MoveItem');
static const FolderEvent MoveFolderItem = FolderEvent._(209, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'MoveFolderItem');
static const FolderEvent ReadTrash = FolderEvent._(300, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ReadTrash');
static const FolderEvent PutbackTrash = FolderEvent._(301, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'PutbackTrash');
static const FolderEvent DeleteTrash = FolderEvent._(302, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DeleteTrash');
@ -54,7 +54,7 @@ class FolderEvent extends $pb.ProtobufEnum {
CopyLink,
SetLatestView,
CloseView,
MoveItem,
MoveFolderItem,
ReadTrash,
PutbackTrash,
DeleteTrash,

View File

@ -30,7 +30,7 @@ const FolderEvent$json = const {
const {'1': 'CopyLink', '2': 206},
const {'1': 'SetLatestView', '2': 207},
const {'1': 'CloseView', '2': 208},
const {'1': 'MoveItem', '2': 209},
const {'1': 'MoveFolderItem', '2': 209},
const {'1': 'ReadTrash', '2': 300},
const {'1': 'PutbackTrash', '2': 301},
const {'1': 'DeleteTrash', '2': 302},
@ -40,4 +40,4 @@ const FolderEvent$json = const {
};
/// Descriptor for `FolderEvent`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List folderEventDescriptor = $convert.base64Decode('CgtGb2xkZXJFdmVudBITCg9DcmVhdGVXb3Jrc3BhY2UQABIUChBSZWFkQ3VyV29ya3NwYWNlEAESEgoOUmVhZFdvcmtzcGFjZXMQAhITCg9EZWxldGVXb3Jrc3BhY2UQAxIRCg1PcGVuV29ya3NwYWNlEAQSFQoRUmVhZFdvcmtzcGFjZUFwcHMQBRINCglDcmVhdGVBcHAQZRINCglEZWxldGVBcHAQZhILCgdSZWFkQXBwEGcSDQoJVXBkYXRlQXBwEGgSDwoKQ3JlYXRlVmlldxDJARINCghSZWFkVmlldxDKARIPCgpVcGRhdGVWaWV3EMsBEg8KCkRlbGV0ZVZpZXcQzAESEgoNRHVwbGljYXRlVmlldxDNARINCghDb3B5TGluaxDOARISCg1TZXRMYXRlc3RWaWV3EM8BEg4KCUNsb3NlVmlldxDQARINCghNb3ZlSXRlbRDRARIOCglSZWFkVHJhc2gQrAISEQoMUHV0YmFja1RyYXNoEK0CEhAKC0RlbGV0ZVRyYXNoEK4CEhQKD1Jlc3RvcmVBbGxUcmFzaBCvAhITCg5EZWxldGVBbGxUcmFzaBCwAg==');
final $typed_data.Uint8List folderEventDescriptor = $convert.base64Decode('CgtGb2xkZXJFdmVudBITCg9DcmVhdGVXb3Jrc3BhY2UQABIUChBSZWFkQ3VyV29ya3NwYWNlEAESEgoOUmVhZFdvcmtzcGFjZXMQAhITCg9EZWxldGVXb3Jrc3BhY2UQAxIRCg1PcGVuV29ya3NwYWNlEAQSFQoRUmVhZFdvcmtzcGFjZUFwcHMQBRINCglDcmVhdGVBcHAQZRINCglEZWxldGVBcHAQZhILCgdSZWFkQXBwEGcSDQoJVXBkYXRlQXBwEGgSDwoKQ3JlYXRlVmlldxDJARINCghSZWFkVmlldxDKARIPCgpVcGRhdGVWaWV3EMsBEg8KCkRlbGV0ZVZpZXcQzAESEgoNRHVwbGljYXRlVmlldxDNARINCghDb3B5TGluaxDOARISCg1TZXRMYXRlc3RWaWV3EM8BEg4KCUNsb3NlVmlldxDQARITCg5Nb3ZlRm9sZGVySXRlbRDRARIOCglSZWFkVHJhc2gQrAISEQoMUHV0YmFja1RyYXNoEK0CEhAKC0RlbGV0ZVRyYXNoEK4CEhQKD1Jlc3RvcmVBbGxUcmFzaBCvAhITCg5EZWxldGVBbGxUcmFzaBCwAg==');

View File

@ -63,7 +63,7 @@ pub fn create(folder: Arc<FolderManager>) -> Module {
.event(FolderEvent::DuplicateView, duplicate_view_handler)
.event(FolderEvent::SetLatestView, set_latest_view_handler)
.event(FolderEvent::CloseView, close_view_handler)
.event(FolderEvent::MoveItem, move_item_handler);
.event(FolderEvent::MoveFolderItem, move_item_handler);
module = module
.event(FolderEvent::ReadTrash, read_trash_handler)
@ -133,7 +133,7 @@ pub enum FolderEvent {
CloseView = 208,
#[event(input = "MoveFolderItemPayload")]
MoveItem = 209,
MoveFolderItem = 209,
#[event(output = "RepeatedTrash")]
ReadTrash = 300,

View File

@ -43,7 +43,7 @@ pub enum FolderEvent {
CopyLink = 206,
SetLatestView = 207,
CloseView = 208,
MoveItem = 209,
MoveFolderItem = 209,
ReadTrash = 300,
PutbackTrash = 301,
DeleteTrash = 302,
@ -76,7 +76,7 @@ impl ::protobuf::ProtobufEnum for FolderEvent {
206 => ::std::option::Option::Some(FolderEvent::CopyLink),
207 => ::std::option::Option::Some(FolderEvent::SetLatestView),
208 => ::std::option::Option::Some(FolderEvent::CloseView),
209 => ::std::option::Option::Some(FolderEvent::MoveItem),
209 => ::std::option::Option::Some(FolderEvent::MoveFolderItem),
300 => ::std::option::Option::Some(FolderEvent::ReadTrash),
301 => ::std::option::Option::Some(FolderEvent::PutbackTrash),
302 => ::std::option::Option::Some(FolderEvent::DeleteTrash),
@ -106,7 +106,7 @@ impl ::protobuf::ProtobufEnum for FolderEvent {
FolderEvent::CopyLink,
FolderEvent::SetLatestView,
FolderEvent::CloseView,
FolderEvent::MoveItem,
FolderEvent::MoveFolderItem,
FolderEvent::ReadTrash,
FolderEvent::PutbackTrash,
FolderEvent::DeleteTrash,
@ -140,7 +140,7 @@ impl ::protobuf::reflect::ProtobufValue for FolderEvent {
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0fevent_map.proto*\xbd\x03\n\x0bFolderEvent\x12\x13\n\x0fCreateWorks\
\n\x0fevent_map.proto*\xc3\x03\n\x0bFolderEvent\x12\x13\n\x0fCreateWorks\
pace\x10\0\x12\x14\n\x10ReadCurWorkspace\x10\x01\x12\x12\n\x0eReadWorksp\
aces\x10\x02\x12\x13\n\x0fDeleteWorkspace\x10\x03\x12\x11\n\rOpenWorkspa\
ce\x10\x04\x12\x15\n\x11ReadWorkspaceApps\x10\x05\x12\r\n\tCreateApp\x10\
@ -148,11 +148,11 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\x10h\x12\x0f\n\nCreateView\x10\xc9\x01\x12\r\n\x08ReadView\x10\xca\x01\
\x12\x0f\n\nUpdateView\x10\xcb\x01\x12\x0f\n\nDeleteView\x10\xcc\x01\x12\
\x12\n\rDuplicateView\x10\xcd\x01\x12\r\n\x08CopyLink\x10\xce\x01\x12\
\x12\n\rSetLatestView\x10\xcf\x01\x12\x0e\n\tCloseView\x10\xd0\x01\x12\r\
\n\x08MoveItem\x10\xd1\x01\x12\x0e\n\tReadTrash\x10\xac\x02\x12\x11\n\
\x0cPutbackTrash\x10\xad\x02\x12\x10\n\x0bDeleteTrash\x10\xae\x02\x12\
\x14\n\x0fRestoreAllTrash\x10\xaf\x02\x12\x13\n\x0eDeleteAllTrash\x10\
\xb0\x02b\x06proto3\
\x12\n\rSetLatestView\x10\xcf\x01\x12\x0e\n\tCloseView\x10\xd0\x01\x12\
\x13\n\x0eMoveFolderItem\x10\xd1\x01\x12\x0e\n\tReadTrash\x10\xac\x02\
\x12\x11\n\x0cPutbackTrash\x10\xad\x02\x12\x10\n\x0bDeleteTrash\x10\xae\
\x02\x12\x14\n\x0fRestoreAllTrash\x10\xaf\x02\x12\x13\n\x0eDeleteAllTras\
h\x10\xb0\x02b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -19,7 +19,7 @@ enum FolderEvent {
CopyLink = 206;
SetLatestView = 207;
CloseView = 208;
MoveItem = 209;
MoveFolderItem = 209;
ReadTrash = 300;
PutbackTrash = 301;
DeleteTrash = 302;

View File

@ -75,6 +75,7 @@ fn crate_log_filter(level: String) -> String {
filters.push(format!("lib_ws={}", level));
filters.push(format!("lib_infra={}", level));
filters.push(format!("flowy_sync={}", level));
// filters.push(format!("lib_dispatch={}", level));
filters.push(format!("dart_ffi={}", "info"));
filters.push(format!("flowy_database={}", "info"));

View File

@ -47,8 +47,17 @@ where
T: std::convert::TryFrom<Bytes, Error = protobuf::ProtobufError>,
{
fn parse_from_bytes(bytes: Bytes) -> Result<Self, DispatchError> {
let data = T::try_from(bytes)?;
Ok(data)
match T::try_from(bytes) {
Ok(data) => Ok(data),
Err(e) => {
tracing::error!(
"Parse payload to {} failed with error: {:?}",
std::any::type_name::<T>(),
e
);
Err(e.into())
}
}
}
}

View File

@ -139,13 +139,14 @@ impl Service<DispatchContext> for DispatchService {
// print_module_map_info(&module_map);
match module_map.get(&request.event) {
Some(module) => {
tracing::trace!("Handle event: {:?} by {:?}", &request.event, module.name);
let fut = module.new_service(());
let service_fut = fut.await?.call(request);
service_fut.await
}
None => {
let msg = format!("Can not find the event handler. {:?}", request);
log::error!("{}", msg);
tracing::error!("{}", msg);
Err(InternalError::HandleNotFound(msg).into())
}
}