Any more specific form of try/catch in bash?

Viewed 34

So I'm new to bash / pretty much any form of automation (honestly, new to linux too). Regardless I'm doing some short kinda useful (for me) scripts and I'm just wondering if this is the a good attempt on what I'm tryna do.

Context: I'm using this free vpn software called protonVPN-cli (jst because). So I'm trying to create a script that can just open protonvpn then auto connect to one of their free servers, if that connection fails since it's common for those free servers to have some errors like being full or some other sht, it'll automatically try to connect again to a different server.

My main question really is, is this the best way to do a try/catch for my case? I just notice sometimes that it's not 100% catching errors. There's also some cases (I think protonvpn specific) where it ask me to click Cancel or Connect further in a window (that doesn't disappear unless clicked).. and I kinda wanna skip those and just try to connect to another server again, is that possible?

script pretty much uses loops as the try/catch... googled it somewhere

until protonvpn-cli c --random
do 
     :
done

are there better ways to handle these specific errors, like I'm actually catching certain errors that the software is throwing? or is that gonna be more complicated like something that the protonvpn app itself gotta implement as a feature

--apologies if it's a dmb question, jst hoping this could be a learning experience lol

0 Answers
Related