Better error handling for cli script