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

fix:change the http error code #68

Closed
wants to merge 6 commits into from
Closed

fix:change the http error code #68

wants to merge 6 commits into from

Conversation

Marsyew
Copy link
Contributor

@Marsyew Marsyew commented Nov 19, 2023

No description provided.

@hongcha98
Copy link
Contributor

Not all the type errors you enumerate here need to come from anyhow::Error. You can customize the source of the error.
You can change it to the following

#[derive(Debug, Error)]
pub enum AppError {
    #[error("resource {0} not found")]
    ResourceNotFound(String),
    #[error("resource {0} already exists")]
    ResourceAlreadyExists(String),
    #[error("internal server error")]
    InternalServerError(anyhow::Error),
}

Then implement the corresponding Response

@hongcha98
Copy link
Contributor

You can define a our Result type and change the function return type from anyhow::Result to our own Result type

@Marsyew Marsyew closed this Nov 20, 2023
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