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

Return OutOfRange instead of StarknetApiError whenever a method can only return OutOfRange #174

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

Conversation

ShahakShama
Copy link
Contributor

@ShahakShama ShahakShama commented Feb 4, 2024

This change is Reviewable

Copy link
Contributor Author

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

+reviewer:@giladchase

Reviewable status: 0 of 7 files reviewed, all discussions resolved (waiting on @giladchase, @nagmo-starkware, and @yair-starkware)

Copy link
Contributor

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @nagmo-starkware, @ShahakShama, and @yair-starkware)


src/lib.rs line 41 at r1 (raw file):

pub struct OutOfRangeError {
    string: String,
}

"out of error" string is redundant, it appears in the variant.
string field also not necessary I think, it is clear what the string means.

Suggestion:

#[error("{0}")]
pub struct OutOfRangeError(String)

src/lib.rs line 47 at r1 (raw file):

        Self::OutOfRange(error)
    }
}

i think that #[from] generates the code removed

Suggestion:

    #[error(transparent)]
    OutOfRange(#[from] OutOfRangeError),
    /// Error when serializing into number.
    #[error(transparent)]
    ParseIntError(#[from] ParseIntError),
    /// Missing resource type / duplicated resource type.
    #[error("Missing resource type / duplicated resource type; got {0}.")]
    InvalidResourceMappingInitializer(String),
}

#[derive(thiserror::Error, Clone, Debug)]
#[error("Out of range {string}.")]
pub struct OutOfRangeError {
    string: String,
}

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.

2 participants