-
-
Notifications
You must be signed in to change notification settings - Fork 498
Add an option to retrieve TLS errors #2449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| use std::fmt; | ||
| use std::{fmt, sync::Arc}; | ||
|
|
||
| use bytes::{Buf, BufMut}; | ||
|
|
||
|
|
@@ -8,16 +8,27 @@ use crate::{ | |
| }; | ||
|
|
||
| /// Transport-level errors occur when a peer violates the protocol specification | ||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||
| #[derive(Debug, Clone)] | ||
| #[non_exhaustive] | ||
| pub struct Error { | ||
| /// Type of error | ||
| pub code: Code, | ||
| /// Frame type that triggered the error | ||
| pub frame: Option<frame::FrameType>, | ||
| /// Human-readable explanation of the reason | ||
| pub reason: String, | ||
| /// An underlying crypto (e.g. TLS) layer error | ||
| pub crypto: Option<Arc<dyn std::error::Error + Send + Sync>>, | ||
| } | ||
|
|
||
| impl PartialEq for Error { | ||
| fn eq(&self, other: &Self) -> bool { | ||
| self.code == other.code | ||
| } | ||
| } | ||
|
|
||
| impl Eq for Error {} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should ditch this impl outright? Users should probably only be performing comparisons on
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would mean dropping
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment seems to be referencing
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I assumed differently, as in that case, there's little difference between
Regarding this, I rewrote the |
||
|
|
||
| impl fmt::Display for Error { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| self.code.fmt(f)?; | ||
|
|
@@ -39,6 +50,19 @@ impl From<Code> for Error { | |
| code: x, | ||
| frame: None, | ||
| reason: "".to_string(), | ||
| crypto: None, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Error { | ||
| /// Construct an error with a code and a reason | ||
| pub fn new(code: Code, reason: String) -> Self { | ||
| Self { | ||
| code, | ||
| frame: None, | ||
| reason, | ||
| crypto: None, | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -79,6 +103,7 @@ macro_rules! errors { | |
| code: Code::$name, | ||
| frame: None, | ||
| reason: reason.into(), | ||
| crypto: None, | ||
| } | ||
| } | ||
| )* | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.