How to throw error and exit with a custom message in python

Calling sys.exit with a string will work. The docs mention this use explicitly:

In particular, sys.exit(“some error message”) is a quick way to exit a program when an error occurs.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)