Azure / Azure/azure-sdk-for-rust
Client methods should be able to return custom errors
- Dominant language
- Rust
- Stars
- 884
- Forks
- 365
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 112
Description
Currently, our [Rust guidelines](https://azure.github.io/azure-sdk/rust_introduction.html#rust-errors) dictate returning an `azure_core::Result` from our client methods, which is re-exported from `typespec` which aliases this as `std::result::Result` where `typespec::error::Error` is modeled after our [REST API guidelines](https://aka.ms/azapi/guidelines).
For TypeSpec-emitted clients that do no return an Azure error, we should support returning custom errors even if basic i.e., just an HTTP status code.
One idea is that we do this unconditionally if emitting a client in an "unbranded" mode.
Another idea would be to just emit code that returns a `std::result::Result` where `E` is the modeled error type IIF `E` isn't modeled after an Azure error response. Note that `typespec::error::Error` does not mention "Azure" - it's a generic definition of Azure error specs.
Contributor guide
Assessment
This issue has not been assessed yet.