Added myexeption to throw errors and show using MyExeption class.
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "parameter.hpp"
|
||||
|
||||
#include "myexeption.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
@@ -20,6 +22,7 @@ using namespace std;
|
||||
|
||||
Parameter::Parameter() {
|
||||
// Simulation Specs
|
||||
|
||||
seed = (int)getValue("seed");
|
||||
numTotalElectrons = (long int)getValue("numTotalElectrons");
|
||||
dt_s = getValue("dt_s");
|
||||
@@ -45,10 +48,11 @@ Parameter::Parameter() {
|
||||
|
||||
// Output
|
||||
numberZBins = getValue ("numberZBins");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
double Parameter::getValue(std::string varName) {
|
||||
double Parameter::getValue(string varName) {
|
||||
char* ext = (char*)("cat");
|
||||
char* str = strdup(varName.c_str());
|
||||
double temp;
|
||||
@@ -58,13 +62,13 @@ double Parameter::getValue(std::string varName) {
|
||||
|
||||
if (getenv("parpath") == NULL)
|
||||
{
|
||||
throw ("Parameter::value: Environment variable parpath not defined.");
|
||||
throw MyException("Parameter::value: Environment variable parpath not defined.");
|
||||
}
|
||||
strcpy(fname, getenv("parpath"));
|
||||
parfile = getenv("parfile");
|
||||
if (parfile == NULL)
|
||||
{
|
||||
throw ("Parameter::value: Environment variable parfile not defined.");
|
||||
throw MyException("Parameter::value: Environment variable parfile not defined.");
|
||||
}
|
||||
if (!ext)
|
||||
{
|
||||
@@ -75,7 +79,7 @@ double Parameter::getValue(std::string varName) {
|
||||
{
|
||||
stringstream ss;
|
||||
ss<<"Parameter::value: Can not open file " <<fname<<".";
|
||||
throw (ss.str());
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
while (!feof(fcat))
|
||||
{
|
||||
@@ -92,7 +96,7 @@ double Parameter::getValue(std::string varName) {
|
||||
|
||||
stringstream ss;
|
||||
ss<<"Parameter::value: Variable "<<str<<" not found.";
|
||||
throw (ss.str());
|
||||
throw MyException(ss.str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user