Target src/main.rs::main()?
There is a lot of way, I advice the simple one, use a loop:

enum Error {
    A,
}

fn run() -&gt; Result&lt;(), Error&gt; {
    if rand::random() {
        Ok(())
    } else {
        Err(Error::A)
    }
}

pub fn main() {
    while let Err(_) = run() {
        println!("Hello");
    }
}


However, be sure the program end maybe add a maximum fail counter.