Skip to content

Commit 3d22f82

Browse files
committed
Gestion fichier JSON vide (json.decoder.JSONDecodeError) ou inexistant (FileNotFoundError)
1 parent 3848289 commit 3d22f82

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎questionnaire.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,19 @@ def lancer(self):
123123
# ).lancer()
124124

125125

126-
127-
filename = "animaux_leschats_confirme.json"
126+
filename = "animaux_leschats_confirme2.json"
128127
try: # Ouverture du fichier JSON
129128
json_file = open(filename, "r")
130-
except:
129+
except FileNotFoundError:
131130
print("Aucun fichier :", filename)
132131
sys.exit()
133132
else:
134133
with json_file:
135134
try: # Lecture du fichier JSON
136135
json_questionnaire = json.load(json_file)
137-
except:
136+
except json.decoder.JSONDecodeError:
138137
print("Aucune donnée JSON dans fichier :",filename)
139138
sys.exit()
140139

141140
# Lancement du questionnaire
142-
Questionnaire(json_questionnaire).lancer()
141+
#Questionnaire(json_questionnaire).lancer()

0 commit comments

Comments
 (0)