[annuaires_pg] Messages d'erreur plus verbeux

This commit is contained in:
Valentin Samir 2013-05-21 13:59:44 +02:00
parent e37c04cdd4
commit dba7ad88e6

View file

@ -35,7 +35,7 @@ def chbre_prises(batiment, chambre = None):
try: try:
return "%03d" % cur.fetchone()[0] return "%03d" % cur.fetchone()[0]
except TypeError: except TypeError:
raise ValueError("Chambre inexistante") raise ValueError("Chambre inexistante bat %r, chbre %r" % (batiment, chambre))
else: else:
cur = conn.cursor() cur = conn.cursor()
cur.execute("SELECT chambre, prise_crans FROM prises WHERE batiment = %s", batiment) cur.execute("SELECT chambre, prise_crans FROM prises WHERE batiment = %s", batiment)
@ -43,7 +43,7 @@ def chbre_prises(batiment, chambre = None):
for chambre, prise_crans in cur.fetchall(): for chambre, prise_crans in cur.fetchall():
ret[chambre] = "%03d" % prise_crans ret[chambre] = "%03d" % prise_crans
if not ret: if not ret:
raise ValueError("Batiment inexistant") raise ValueError("Batiment %s inexistant" % batiment)
return ret return ret
@_need_conn @_need_conn
@ -56,7 +56,7 @@ def chbre_commentaire(batiment, chambre):
try: try:
return cur.fetchone()[0] return cur.fetchone()[0]
except TypeError: except TypeError:
raise ValueError("Chambre inexistante") raise ValueError("Chambre inexistante bat %r, chbre %r" % (batiment, chambre))
@_need_conn @_need_conn
def reverse(batiment, prise = None): def reverse(batiment, prise = None):
@ -68,7 +68,7 @@ def reverse(batiment, prise = None):
try: try:
return [chbre for (chbre,) in cur.fetchall()] return [chbre for (chbre,) in cur.fetchall()]
except TypeError: except TypeError:
raise ValueError("Prise inexistante") raise ValueError("Prise %s inexistante" % prise)
else: else:
cur = conn.cursor() cur = conn.cursor()
cur.execute("SELECT chambre, prise_crans FROM prises WHERE batiment = %s", batiment) cur.execute("SELECT chambre, prise_crans FROM prises WHERE batiment = %s", batiment)
@ -80,7 +80,7 @@ def reverse(batiment, prise = None):
ret["%03d" % prise_crans] = [chambre] ret["%03d" % prise_crans] = [chambre]
if not ret: if not ret:
raise ValueError("Batiment inexistant") raise ValueError("Batiment %s inexistant" % batiment)
return ret return ret
@_need_conn @_need_conn