Skip to content

Instantly share code, notes, and snippets.

@faul-sname
faul-sname / demo.rs
Created August 21, 2023 20:28
What code looks like with explicit error handling at every step
// Fetch the OpenAPI yaml file
fn fetch_openapi() -> Result<String, reqwest::Error> {
let url = "https://example.com/openapi.yaml";
match reqwest::blocking::get(url) {
Ok(response) => match response.text() {
Ok(text) => Ok(text),
Err(e) => Err(e),
},
Err(e) => Err(e),
}