Skip to content

Commit 15ff555

Browse files
authored
feat(socketio/connect): emit extractor errors in middlewares
1 parent a38046b commit 15ff555

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

socketioxide/src/handler/connect.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub(crate) trait ErasedConnectHandler<A: Adapter>: Send + Sync + 'static {
8585
/// * See the [`extract`](super::extract) module doc for more details on available extractors.
8686
pub trait FromConnectParts<A: Adapter>: Sized {
8787
/// The error type returned by the extractor
88-
type Error: std::error::Error + 'static;
88+
type Error: std::error::Error + Send + 'static;
8989

9090
/// Extract the arguments from the connect event.
9191
/// If it fails, the handler is not called
@@ -350,10 +350,10 @@ macro_rules! impl_middleware_async {
350350
$(
351351
let $ty = match $ty::from_connect_parts(&s, &auth) {
352352
Ok(v) => v,
353-
Err(_e) => {
353+
Err(e) => {
354354
#[cfg(feature = "tracing")]
355-
tracing::error!("Error while extracting data: {}", _e);
356-
return Ok(());
355+
tracing::error!("Error while extracting data: {}", e);
356+
return Err(Box::new(e) as _);
357357
},
358358
};
359359
)*
@@ -387,12 +387,10 @@ macro_rules! impl_middleware {
387387
$(
388388
let $ty = match $ty::from_connect_parts(&s, &auth) {
389389
Ok(v) => v,
390-
Err(_e) => {
390+
Err(e) => {
391391
#[cfg(feature = "tracing")]
392-
tracing::error!("Error while extracting data: {}", _e);
393-
394-
//TODO: handle error
395-
return Ok(());
392+
tracing::error!("Error while extracting data: {}", e);
393+
return Err(Box::new(e) as _);
396394
},
397395
};
398396
)*

0 commit comments

Comments
 (0)