-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: replace unwraps with errors in fullstack WebSockets #5248
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
Conversation
|
|
||
| /// Error during serialization/deserialization. | ||
| #[error("serde_json error")] | ||
| Json(#[from] serde_json::Error), | ||
|
|
||
| /// Error during serialization/deserialization. | ||
| #[error("ciborium error")] | ||
| Cbor(#[from] ciborium::de::Error<std::io::Error>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are used nowhere.
packages/fullstack-core/src/error.rs
Outdated
| .status() | ||
| .as_ref() | ||
| .map(StatusCode::as_u16) | ||
| .unwrap_or(DEFAULT_STATUS_CODE), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how you guys handle these kinds of cases. This code returns a zero status code, which is not very valid (even the StatusCode type accepts only NonZeroU16).
I guess after checking that value.is_status() (which this code does), we could just do something like .expect("status code not present when is_status is true"), but that could theoretically panic, which is exactly what this PR is trying to avoid.
| let response = native::send_request(request, &self.protocols) | ||
| .await | ||
| .unwrap(); | ||
| let response = native::send_request(request, &self.protocols).await?; | ||
|
|
||
| let (inner, protocol) = response | ||
| .into_stream_and_protocol(self.protocols, None) | ||
| .await | ||
| .unwrap(); | ||
| .await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the whole point of this PR. Everything else are required error type conversions.
|
I would prefer we not pull in large deps in the fullstack-core crate. Can we just place the conversions inline in the higher level crates? Placing them too low bloats the compile graph and slows down our compile times. |
|
Sure, is it okay like this? |
Similarly to #4916, closes #5247.