Commit e55e99dcc251423bef10f962d8eff992f0b0b661
1 parent
e110f713
add file_function_value exception and rename to file_function_data and file_function_columns
Showing
2 changed files
with
65 additions
and
20 deletions
include/GException.hpp
| ... | ... | @@ -535,15 +535,20 @@ public: |
| 535 | 535 | model_invalid_parscale(std::string origin, GXmlElement xml, |
| 536 | 536 | std::string message = ""); |
| 537 | 537 | }; |
| 538 | - class not_enough_data : public GExceptionHandler { | |
| 538 | + class file_function_data : public GExceptionHandler { | |
| 539 | 539 | public: |
| 540 | - not_enough_data(std::string origin, std::string filename, | |
| 541 | - int num, std::string message = ""); | |
| 540 | + file_function_data(std::string origin, std::string filename, | |
| 541 | + int num, std::string message = ""); | |
| 542 | 542 | }; |
| 543 | - class not_enough_columns : public GExceptionHandler { | |
| 543 | + class file_function_columns : public GExceptionHandler { | |
| 544 | 544 | public: |
| 545 | - not_enough_columns(std::string origin, std::string filename, | |
| 546 | - int num, std::string message = ""); | |
| 545 | + file_function_columns(std::string origin, std::string filename, | |
| 546 | + int num, std::string message = ""); | |
| 547 | + }; | |
| 548 | + class file_function_value : public GExceptionHandler { | |
| 549 | + public: | |
| 550 | + file_function_value(std::string origin, std::string filename, | |
| 551 | + double value, std::string message = ""); | |
| 547 | 552 | }; |
| 548 | 553 | class par_not_found : public GExceptionHandler { |
| 549 | 554 | public: | ... | ... |
src/model/GException_model.cpp
| ... | ... | @@ -4,10 +4,18 @@ |
| 4 | 4 | * copyright (C) 2010-2011 by Jurgen Knodlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | - * This program is free software; you can redistribute it and/or modify * | |
| 8 | - * it under the terms of the GNU General Public License as published by * | |
| 9 | - * the Free Software Foundation; either version 2 of the License, or * | |
| 10 | - * (at your option) any later version. * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 11 | 19 | * * |
| 12 | 20 | ***************************************************************************/ |
| 13 | 21 | /** |
| ... | ... | @@ -259,16 +267,19 @@ GException::model_invalid_parscale::model_invalid_parscale(std::string origin, |
| 259 | 267 | * @param[in] num Number of nodes. |
| 260 | 268 | * @param[in] message Optional error message. |
| 261 | 269 | ***************************************************************************/ |
| 262 | -GException::not_enough_data::not_enough_data(std::string origin, | |
| 263 | - std::string filename, | |
| 264 | - int num, | |
| 265 | - std::string message) | |
| 270 | +GException::file_function_data::file_function_data(std::string origin, | |
| 271 | + std::string filename, | |
| 272 | + int num, | |
| 273 | + std::string message) | |
| 266 | 274 | { |
| 267 | 275 | // Set origin and message |
| 268 | 276 | m_origin = origin; |
| 269 | 277 | m_message = "File function \""+filename+"\" contains "+str(num)+ |
| 270 | 278 | " energy nodes while at least 2 are required to describe a" |
| 271 | - " spectral shape. "+message; | |
| 279 | + " spectral shape."; | |
| 280 | + if (message.length() > 0) { | |
| 281 | + m_message += " "+message; | |
| 282 | + } | |
| 272 | 283 | |
| 273 | 284 | // Return |
| 274 | 285 | return; |
| ... | ... | @@ -283,16 +294,45 @@ GException::not_enough_data::not_enough_data(std::string origin, |
| 283 | 294 | * @param[in] num Number of columns. |
| 284 | 295 | * @param[in] message Optional error message. |
| 285 | 296 | ***************************************************************************/ |
| 286 | -GException::not_enough_columns::not_enough_columns(std::string origin, | |
| 287 | - std::string filename, | |
| 288 | - int num, | |
| 289 | - std::string message) | |
| 297 | +GException::file_function_columns::file_function_columns(std::string origin, | |
| 298 | + std::string filename, | |
| 299 | + int num, | |
| 300 | + std::string message) | |
| 290 | 301 | { |
| 291 | 302 | // Set origin and message |
| 292 | 303 | m_origin = origin; |
| 293 | 304 | m_message = "File function \""+filename+"\" contains "+str(num)+ |
| 294 | 305 | " columns while at least 2 are required to define" |
| 295 | - " energy and intensity. "+message; | |
| 306 | + " energy and intensity."; | |
| 307 | + if (message.length() > 0) { | |
| 308 | + m_message += " "+message; | |
| 309 | + } | |
| 310 | + | |
| 311 | + // Return | |
| 312 | + return; | |
| 313 | +} | |
| 314 | + | |
| 315 | + | |
| 316 | +/***********************************************************************//** | |
| 317 | + * @brief Invalid value in file function | |
| 318 | + * | |
| 319 | + * @param[in] origin Method that throws the error. | |
| 320 | + * @param[in] filename File function filename. | |
| 321 | + * @param[in] num Number of columns. | |
| 322 | + * @param[in] message Optional error message. | |
| 323 | + ***************************************************************************/ | |
| 324 | +GException::file_function_value::file_function_value(std::string origin, | |
| 325 | + std::string filename, | |
| 326 | + double value, | |
| 327 | + std::string message) | |
| 328 | +{ | |
| 329 | + // Set origin and message | |
| 330 | + m_origin = origin; | |
| 331 | + m_message = "Invalid value \""+str(value)+"\" encountered in" | |
| 332 | + " file function \""+filename+"\"."; | |
| 333 | + if (message.length() > 0) { | |
| 334 | + m_message += " "+message; | |
| 335 | + } | |
| 296 | 336 | |
| 297 | 337 | // Return |
| 298 | 338 | return; | ... | ... |