Skip to content

Commit

Permalink
chore: add more error info
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsusinn committed Jan 23, 2025
1 parent 2a96237 commit 2385876
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
39 changes: 39 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tuic-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ humantime-serde = "1"
# Logging
time = { version = "0.3", features = ["macros", "local-offset"] }
humantime = { version = "2", default-features = false }
tracing-subscriber = { version = "0.3", default-features = false, features = ["tracing-log", "std", "local-time","fmt"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["tracing-log", "std", "local-time","fmt", "ansi"] }
chrono = "0.4"
tracing = "0.1"

Expand Down
12 changes: 9 additions & 3 deletions tuic-server/src/connection/handle_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ impl Connection {
addr = self.inner.remote_address(),
user = self.auth,
);
self.close();
self.close(&format!(
"A serious error occurred at unidirectional stream pre-process stage {err}"
));
}
}
}
Expand Down Expand Up @@ -118,7 +120,9 @@ impl Connection {
addr = self.inner.remote_address(),
user = self.auth,
);
self.close();
self.close(&format!(
"A serious error occurred at bidirectional stream pre-process stage {err}"
));
}
}
}
Expand Down Expand Up @@ -159,7 +163,9 @@ impl Connection {
addr = self.inner.remote_address(),
user = self.auth,
);
self.close();
self.close(&format!(
"A serious error occurred at datagram pre-process stage {err}"
));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions tuic-server/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Connection {
id = self.id(),
addr = self.inner.remote_address(),
);
self.close();
self.close("Authentication error");
}
}
}
Expand Down Expand Up @@ -192,7 +192,7 @@ impl Connection {
self.inner.close_reason().is_some()
}

fn close(&self) {
self.inner.close(ERROR_CODE, &[]);
fn close(&self, reason: &str) {
self.inner.close(ERROR_CODE, reason.as_bytes());
}
}

0 comments on commit 2385876

Please sign in to comment.