use scoped_error::{Error, bail, expect_error};
fn connect(url: &str) -> Result<String, Error> {
expect_error("Failed to connect to target", || {
if !url.is_empty() {
return Ok("connected".to_string());
}
bail!("invalid URL [{}]", url);
})
}
fn main() -> Result<(), Error> {
expect_error("This program will error", || {
connect("")?;
Ok(())
})
}