MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / resolve_with_fallback

Function resolve_with_fallback

crates/opencode-provider/src/openai.rs:1086–1099  ·  view source on GitHub ↗
(
    primary: PFut,
    fallback: F,
)

Source from the content-addressed store, hash-verified

1084}
1085
1086async fn resolve_with_fallback<T, PFut, FFut, F>(
1087 primary: PFut,
1088 fallback: F,
1089) -> Result<T, ProviderError>
1090where
1091 PFut: Future<Output = Result<T, ProviderError>>,
1092 F: FnOnce(ProviderError) -> FFut,
1093 FFut: Future<Output = Result<T, ProviderError>>,
1094{
1095 match primary.await {
1096 Ok(value) => Ok(value),
1097 Err(err) => fallback(err).await,
1098 }
1099}
1100
1101#[cfg(test)]
1102mod tests {

Calls

no outgoing calls

Tested by

no test coverage detected