aboutsummaryrefslogtreecommitdiff
path: root/api.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-09-24 16:57:10 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-09-24 16:57:10 +0530
commit0ff2f3189ea5aea74303138b531994026222d524 (patch)
treef68b69293c3a03cbf364874c93e76f0166003455 /api.py
parenta3e3511e3b6a7419ce5aed5847e481595971b7bc (diff)
added exception handling for unknown hostname
Diffstat (limited to 'api.py')
-rw-r--r--api.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/api.py b/api.py
index db7a881..e7ac8cd 100644
--- a/api.py
+++ b/api.py
@@ -19,13 +19,16 @@ def gen_word(N, min_N_dig, min_N_low):
dbFailing = False
import mysql.connector as con
-from mysql.connector.errors import InterfaceError
+from mysql.connector.errors import InterfaceError, DatabaseError
try:
mycon = con.connect(host=flask_app.config['DB_HOST'],user=flask_app.config['DB_USER'],password=flask_app.config['DB_PASSWORD'],port=flask_app.config['DB_PORT'],database=flask_app.config['DB_NAME'])
mycursor = mycon.cursor()
except InterfaceError:
print("Could not connect to the database!")
dbFailing = True
+except DatabaseError:
+ print("Unknown Host")
+ dbFailing = True
"""
@flask_app.route("/")