Skip to content
This repository has been archived by the owner on Apr 10, 2021. It is now read-only.

error handling #26

Closed
ctaggart opened this issue Oct 6, 2020 · 3 comments
Closed

error handling #26

ctaggart opened this issue Oct 6, 2020 · 3 comments

Comments

@ctaggart
Copy link
Owner

ctaggart commented Oct 6, 2020

Do we wish to use a structured Error type like surf 2 moved to?
https://github.com/http-rs/surf/releases/tag/v2.0.0
https://blog.yoshuawuyts.com/async-http/#error-handling

@ctaggart
Copy link
Owner Author

Currently just using:

pub type Error = Box<dyn std::error::Error + Send + Sync>;
pub type Result<T> = std::result::Result<T, Error>;
 
   Ok(res.json().await?)

In some use cases, it would be good to add more context, like the full response. Here I was using anyhow crate to achieve that.

    let res = client.execute(req).await?;
    match res.error_for_status_ref() {
        Ok(_) => Ok(res.json().await?),
        Err(err) => {
            let e = Error::new(err);
            let e = e.context(res.text().await?);
            Err(e)
        }
    }

ctaggart added a commit to ctaggart/azure-sdk-for-rust that referenced this issue Oct 12, 2020
ctaggart added a commit that referenced this issue Oct 12, 2020
ctaggart added a commit that referenced this issue Oct 12, 2020
@ctaggart
Copy link
Owner Author

Planned implementation is listed in Azure/azure-sdk-for-rust#47

@ctaggart
Copy link
Owner Author

fixed by #63

ctaggart added a commit to Azure/azure-sdk-for-rust that referenced this issue Oct 20, 2020
* add azure_mgmt_storage_v2019_06_01

* headers now generated

* all local types in same mod

* include referenced types

* CamelCase for vec types

* fix referenced schemas

* add referenced schemas recursively

* multiple input files
ctaggart/autorust#38

* create local structs

* move to rest/mgmt_storage/2019-06-01

* unlock build on other branches

* add rest/rustfmt.toml

* allOf & pub

* optional params

* default Configuration

* added mgmt_storage 2020-08-01-preview

* API_VERSION const

* api-version from config

* query params

* map with Vec::is_empty

* skip_serializing if readOnly

* remove anyhow dependency
ctaggart/autorust#26

* remove if statement around api-version param

* switch services layout to be like go sdk

* add compute_mgmt example

* add body and header params

* add avs_mgmt

* group operations into modules

* add resources mgmt

* service api versions as features

* add two examples

* version modules

* add avs_private_cloud_list example

* vm_list example

* switch name back to azure_mgmt_${service} #42

* many compute API versions

* add 70 mgmt services

* map all respones with error handling

* +30  mgmt services, 100 total

* use spec folder names

* add readme for Azure Service Crates

* fix vmware example & add examples to readme

* add storage account list to readme

* docs are hard
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant