-
Notifications
You must be signed in to change notification settings - Fork 9
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
Use strongly typed errors based on thiserror #134
base: main
Are you sure you want to change the base?
Conversation
Dyn<error> is generally discouraged in libraries.
|
||
### Changed | ||
|
||
- Error hierarchy revamp to structured errors based on thiserror crate |
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.
- Error hierarchy revamp to structured errors based on thiserror crate | |
- Error hierarchy revamp to structured errors based on `thiserror` crate |
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.
Nit: maybe link to it too thiserror ?
#[derive(Debug, Clone)] | ||
pub struct ResponseContent<T> { | ||
pub struct ResponseContent<T: std::fmt::Debug> { |
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.
Nit / style:
I think the preferred way would be to
use std::fmt::Debug;
and then:
pub struct ResponseContent<T: std::fmt::Debug> { | |
pub struct ResponseContent<T: Debug> { |
Applied to all instances of std::fmt::Debug
.
And then the same would apply for Display
trait below at line 8.
#[error("reqwest error: {0}")] | ||
Reqwest(#[from] reqwest::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.
I wonder if it isn't better to use #[error(transparent)]
attribute on these as we are basically just passing them over to the caller.
#[error("reqwest error: {0}")] | |
Reqwest(#[from] reqwest::Error), | |
#[error(transparent)] | |
Reqwest(#[from] reqwest::Error), |
I guess it would make sense to use the current form if we intended to add some more details to the error.
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
|
|||
## [Unreleased] | |||
|
|||
## [0.3.4] - 2024-08-27 |
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.
Given that 0.4.0
went in but hasn't been released yet, should we include these changes in the same version too?
@@ -39,7 +39,7 @@ impl FalconHandle { | |||
Ok(()) | |||
} | |||
|
|||
pub async fn from_env() -> Result<Self, Box<dyn std::error::Error>> { | |||
pub async fn from_env() -> Result<Self, crate::error::CredentialsError> { |
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.
pub async fn from_env() -> Result<Self, crate::error::CredentialsError> { | |
pub async fn from_env() -> Result<Self, CredentialsError> { |
Dyn is generally discouraged in libraries.
Reraise of #131 from a branch instead of main in my fork. It's easier to keep fork:main in sync and rebase feature branch as upstream progresses.