From b861b770f8252c8fe53ea56b864f7628aa55285a Mon Sep 17 00:00:00 2001 From: Fred Z Date: Fri, 9 Feb 2018 18:10:32 +0100 Subject: [PATCH] =?UTF-8?q?Plus=20de=20details=20sur=20les=20retours=20d'e?= =?UTF-8?q?xceptions|TP=5F3.9|UPDATE=C2=A0roboc.py=20&=20map.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roboc/map.py | 3 ++- roboc/roboc.py | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/roboc/map.py b/roboc/map.py index 9c88a72..3915276 100644 --- a/roboc/map.py +++ b/roboc/map.py @@ -46,7 +46,8 @@ class Map: self._line_nb = len(self._data_list) # Contient le contenu de la carte en texte else: - raise ValueError('ERR_MAP_FILE') + raise FileNotFoundError('ERR_MAP_FILE: {}'.format(map_file)) + line = int(self._line_nb) while line == 0: diff --git a/roboc/roboc.py b/roboc/roboc.py index 0aa6fda..90be50b 100644 --- a/roboc/roboc.py +++ b/roboc/roboc.py @@ -20,8 +20,7 @@ une sortie. Arrive sur ce point, la partie est terminee. """ -# from map import * -# from game import * +from map import Map import os import pickle @@ -41,6 +40,7 @@ MSG_DISCLAMER = "Bienvenue dans Roboc." MSG_AVAIBLE_MAP = "Cartes disponible: " MSG_CHOOSE_MAP = "Choississez un numéro de carte: " MSG_SELECTED_MAP = "Vous avez fait le choix #{}, la carte «{}»." +DEBUG = False # VARIABLES maps_name_list = list() # liste des maps proposees a l'utilisateur @@ -84,8 +84,11 @@ while selected_map > len(maps_name_list) or selected_map < 0: selected_map = input(MSG_CHOOSE_MAP) try: selected_map = int(selected_map) - except ValueError: - print(ERR_SAISIE) + except ValueError as except_detail: + if DEBUG: + print("ValueError: «{}»".format(except_detail)) + else: + print(ERR_SAISIE) selected_map = -1 continue