-
Notifications
You must be signed in to change notification settings - Fork 118
Consider a explicit Operation to Error conversion #3505
Copy link
Copy link
Closed
Labels
api: computeIssues related to the Compute Engine API.Issues related to the Compute Engine API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Milestone
Description
The GCE status codes (at least for LROs) are very different from standard status codes:
Instead of automatically converting Operation to Result<Operation> maybe we should expose an explicit function, something like:
impl Operation {
pub fn to_result(self) -> std::result::Result<Operation, OperationError> {
if self.error.is_none() {
return Ok(self)
}
// Map the `error` and `error.errors` to an specific error type, preserving all the data.
}
}So an LRO becomes:
let operation = client.insert().set_project(..).set_body(...).poller().until_done().await?;
// here one can use operation.error.is_some() and get the error details manually, or maybe:
let operation = operation.to_result()?; // automatically return when using `anyhow::Result` or a similar return type. Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: computeIssues related to the Compute Engine API.Issues related to the Compute Engine API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.