Commit 898f7a2af41140d361640aec499b7b4ad491e619

Authored by knodlseder
1 parent 0be65377

add not_enough_data and not_enough_columns exceptions

include/GException.hpp
... ... @@ -458,6 +458,16 @@ public:
458 458 model_invalid_parnames(std::string origin, GXmlElement xml,
459 459 std::string message = "");
460 460 };
  461 + class not_enough_data : public GExceptionHandler {
  462 + public:
  463 + not_enough_data(std::string origin, std::string filename,
  464 + int num, std::string message = "");
  465 + };
  466 + class not_enough_columns : public GExceptionHandler {
  467 + public:
  468 + not_enough_columns(std::string origin, std::string filename,
  469 + int num, std::string message = "");
  470 + };
461 471  
462 472  
463 473 // GCvs exceptions
... ...
src/model/GException_model.cpp
... ... @@ -10,13 +10,18 @@
10 10 * (at your option) any later version. *
11 11 * *
12 12 ***************************************************************************/
  13 +/**
  14 + * @file GException_model.cpp
  15 + * @brief Implement exceptions for the model module
  16 + * @author J. Knodlseder
  17 + */
13 18  
14 19 /* __ Includes ___________________________________________________________ */
15 20 #ifdef HAVE_CONFIG_H
16 21 #include <config.h>
17 22 #endif
18 23 #include "GException.hpp"
19   -//#include "GTools.hpp"
  24 +#include "GTools.hpp"
20 25  
21 26  
22 27 /***********************************************************************//**
... ... @@ -101,3 +106,51 @@ GException::model_invalid_parnames::model_invalid_parnames(std::string origin,
101 106 // Return
102 107 return;
103 108 }
  109 +
  110 +
  111 +/***********************************************************************//**
  112 + * @brief Not enough nodes in file function
  113 + *
  114 + * @param[in] origin Method that throws the error.
  115 + * @param[in] filename File function filename.
  116 + * @param[in] num Number of nodes.
  117 + * @param[in] message Optional error message.
  118 + ***************************************************************************/
  119 +GException::not_enough_data::not_enough_data(std::string origin,
  120 + std::string filename,
  121 + int num,
  122 + std::string message)
  123 +{
  124 + // Set origin and message
  125 + m_origin = origin;
  126 + m_message = "File function \""+filename+"\" contains "+str(num)+
  127 + " energy nodes while at least 2 are required to describe a"
  128 + " spectral shape. "+message;
  129 +
  130 + // Return
  131 + return;
  132 +}
  133 +
  134 +
  135 +/***********************************************************************//**
  136 + * @brief Not enough columns in file function
  137 + *
  138 + * @param[in] origin Method that throws the error.
  139 + * @param[in] filename File function filename.
  140 + * @param[in] num Number of columns.
  141 + * @param[in] message Optional error message.
  142 + ***************************************************************************/
  143 +GException::not_enough_columns::not_enough_columns(std::string origin,
  144 + std::string filename,
  145 + int num,
  146 + std::string message)
  147 +{
  148 + // Set origin and message
  149 + m_origin = origin;
  150 + m_message = "File function \""+filename+"\" contains "+str(num)+
  151 + " columns while at least 2 are required to define"
  152 + " energy and intensity. "+message;
  153 +
  154 + // Return
  155 + return;
  156 +}
... ...