Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomaszjonak
Copy link
Collaborator

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.

Dyn<error> is generally discouraged in libraries.

### Changed

- Error hierarchy revamp to structured errors based on thiserror crate
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Error hierarchy revamp to structured errors based on thiserror crate
- Error hierarchy revamp to structured errors based on `thiserror` crate

Copy link
Collaborator

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> {
Copy link
Collaborator

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:

Suggested change
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.

Comment on lines +18 to +19
#[error("reqwest error: {0}")]
Reqwest(#[from] reqwest::Error),
Copy link
Collaborator

@makr11st makr11st Aug 27, 2024

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.

Suggested change
#[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
Copy link
Collaborator

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> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub async fn from_env() -> Result<Self, crate::error::CredentialsError> {
pub async fn from_env() -> Result<Self, CredentialsError> {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants