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

@ -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())
}
}