diff --git a/include/GException.hpp b/include/GException.hpp index 7a50193..3c94844 100644 --- a/include/GException.hpp +++ b/include/GException.hpp @@ -459,6 +459,15 @@ public: std::string message = ""); }; + + // GCvs exceptions + class cvs_bad_columns : public GExceptionHandler { + public: + cvs_bad_columns(std::string origin, std::string filename, + int rows, int cols, int elements, + std::string message = ""); + }; + }; #endif /* GEXCEPTION_HPP */ diff --git a/src/support/GException.cpp b/src/support/GException.cpp index dfab5c0..7816150 100644 --- a/src/support/GException.cpp +++ b/src/support/GException.cpp @@ -50,6 +50,7 @@ GException::feature_not_implemented::feature_not_implemented(std::string origin, " https://sourceforge.net/projects/gammalib/," " join this error message and provide a detailed" " description of your needs."; + return; } @@ -63,6 +64,7 @@ GException::bad_type::bad_type(std::string origin, std::string message) { m_origin = origin; m_message = "Invalud type conversion. " + message; + return; } @@ -76,6 +78,7 @@ GException::mem_alloc::mem_alloc(std::string origin, unsigned num) { m_origin = origin; m_message = "Memory allocation error (" + str((int)num) + " elements)"; + return; } @@ -89,6 +92,7 @@ GException::not_enough_nodes::not_enough_nodes(std::string origin, int num) { m_origin = origin; m_message = "Not enough nodes in node array (" + str(num) + " nodes)."; + return; } @@ -102,6 +106,7 @@ GException::file_not_found::file_not_found(std::string origin, std::string filen { m_origin = origin; m_message = "File \"" + filename +"\" not found."; + return; } @@ -115,4 +120,30 @@ GException::file_open_error::file_open_error(std::string origin, std::string fil { m_origin = origin; m_message = "Unable to open file \"" + filename +"\""; + return; +} + + +/***********************************************************************//** + * @brief Bad CSV columns encountered + * + * @param[in] origin Name of method that has thrown the exception. + * @param[in] filename Filename. + * @param[in] row CSV file row. + * @param[in] cols Expected number of columns. + * @param[in] elements Found number of columns. + * @param[in] message Optional message. + ***************************************************************************/ +GException::cvs_bad_columns::cvs_bad_columns(std::string origin, + std::string filename, + int row, + int cols, + int elements, + std::string message) +{ + m_origin = origin; + m_message = "Inconsistent number of columns found in row "+str(row)+ + " of file \""+filename+"\" ("+str(cols)+" expected, "+ + str(elements)+" encountered). "+message; + return; }