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

When will sync::Api::new() return an Result::Err()? #52

Open
Adamska1008 opened this issue Mar 28, 2024 · 0 comments
Open

When will sync::Api::new() return an Result::Err()? #52

Adamska1008 opened this issue Mar 28, 2024 · 0 comments

Comments

@Adamska1008
Copy link

Adamska1008 commented Mar 28, 2024

I try to handle the Error that Api::new() may return, but it seems that it never returns a error. Here's the related code in latest commit 6303587576f8a1ce9f91f8274265a153b89afb6e:

// src/api/sync.rs
impl Api {
    /// Creates a default Api, for Api options See [`ApiBuilder`]
    pub fn new() -> Result<Self, ApiError> {
        ApiBuilder::new().build()
    }
// ...
}
// src/api/sync.rs
impl ApiBuilder {
//...
    /// Consumes the builder and buids the final [`Api`]
    pub fn build(self) -> Result<Api, ApiError> {
        let headers = self.build_headers();

        let agent = ureq::builder().try_proxy_from_env(true).build();
        let client = HeaderAgent::new(agent, headers.clone());

        let no_redirect_agent = ureq::builder()
            .try_proxy_from_env(true)
            .redirects(0)
            .build();
        let no_redirect_client = HeaderAgent::new(no_redirect_agent, headers);

        Ok(Api {
            endpoint: self.endpoint,
            url_template: self.url_template,
            cache: self.cache,
            client,

            no_redirect_client,
            progress: self.progress,
        })
    }
}

Is it possible to modify the return value definition of this method?

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

No branches or pull requests

1 participant