From 6006fee7b9eddd71dee20b6b39b233f7e4088db9 Mon Sep 17 00:00:00 2001 From: schodet Date: Thu, 13 May 2004 23:10:37 +0000 Subject: Virure de Erreur --- 2004/i/nono/src/config/config.cc | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to '2004/i/nono/src/config/config.cc') diff --git a/2004/i/nono/src/config/config.cc b/2004/i/nono/src/config/config.cc index 9a88494..ea726c6 100644 --- a/2004/i/nono/src/config/config.cc +++ b/2004/i/nono/src/config/config.cc @@ -24,9 +24,20 @@ // }}} #include "config.h" #include "config_lex.h" -#include "erreur/erreur.h" #include +#include + +const char * +ConfigError::what () const throw () +{ + static char descr[1024]; + if (!m_id) + sprintf (descr, "%s: %s", m_file, m_descr); + else + sprintf (descr, "%s: %s: %s", m_file, m_id, m_descr); + return descr; +} // Constructeur, prend l'identificateur de configuration en paramètre (nom de // fichier). @@ -54,7 +65,7 @@ Config::getNum (void) { if (m_type == -1) m_type = config_yylex (); if (m_type != NUM) - throw ErreurConfig (m_filename.c_str (), "Nombre attendu.\n"); + throw ConfigError (m_filename.c_str (), "Nombre attendu.\n"); m_type = -1; return config_yylval.num; } @@ -64,7 +75,7 @@ Config::getId (void) { if (m_type == -1) m_type = config_yylex (); if (m_type != ID) - throw ErreurConfig (m_filename.c_str (), "Identificateur attendu.\n"); + throw ConfigError (m_filename.c_str (), "Identificateur attendu.\n"); m_type = -1; return config_yylval.id; } @@ -74,7 +85,7 @@ Config::getId (std::string &s) { if (m_type == -1) m_type = config_yylex (); if (m_type != ID) - throw ErreurConfig (m_filename.c_str (), "Identificateur attendu.\n"); + throw ConfigError (m_filename.c_str (), "Identificateur attendu.\n"); m_type = -1; s = config_yylval.id; } @@ -84,7 +95,7 @@ Config::getBool (void) { if (m_type == -1) m_type = config_yylex (); if (m_type != BOOL) - throw ErreurConfig (m_filename.c_str (), "Booléen attendu.\n"); + throw ConfigError (m_filename.c_str (), "Booléen attendu.\n"); m_type = -1; return config_yylval.boolean; } @@ -104,7 +115,7 @@ Config::getFloat (void) return (double) config_yylval.num; } else - throw ErreurConfig (m_filename.c_str (), "Flotant attendu.\n"); + throw ConfigError (m_filename.c_str (), "Flotant attendu.\n"); } void @@ -112,7 +123,7 @@ Config::getString (std::string &s) { if (m_type == -1) m_type = config_yylex (); if (m_type != STRING) - throw ErreurConfig (m_filename.c_str (), + throw ConfigError (m_filename.c_str (), "Chaîne de caractères attendue.\n"); m_type = -1; s = config_yylval.str; @@ -123,7 +134,7 @@ Config::getEof (void) { if (m_type == -1) m_type = config_yylex (); if (m_type) - throw ErreurConfig (m_filename.c_str (), + throw ConfigError (m_filename.c_str (), "Fin de fichier attendue.\n"); } @@ -141,7 +152,7 @@ Config::isId (const char *s) { if (m_type == -1) m_type = config_yylex (); if (m_type != ID) - throw ErreurConfig (m_filename.c_str (), "Identificateur attendu.\n"); + throw ConfigError (m_filename.c_str (), "Identificateur attendu.\n"); return strcmp (config_yylval.id, s) == 0; } @@ -149,14 +160,14 @@ Config::isId (const char *s) void Config::noId (void) { - throw ErreurConfig (m_filename.c_str (), config_yylval.id, + throw ConfigError (m_filename.c_str (), config_yylval.id, "Identificateur inconnu.\n"); } void Config::throwError (const char *msg) { - throw ErreurConfig (m_filename.c_str (), msg); + throw ConfigError (m_filename.c_str (), msg); } // Appellé par le lexer pour changer de fichier. -- cgit v1.2.3