Is either of these methods proper? I am trying to get a general 'this script failed' type of exception to send a message to the log table. the script is run from command line initiate by an ansible play (shell module with async:0 poll: 0). Throughout main() and the various functions, I send status messages to the log table, but I need to know if the script fails at all.
main()
try:
logic()
if more code:
more_logic()
except:
send_error()
or isit better like this:
if __name__ == "__main__":
try:
main()
except:
send_error()
Thanks