Skip to content

Commit

Permalink
Use error messages instead of error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
HomesGH committed Oct 4, 2024
1 parent de95eaa commit 12a8e32
Show file tree
Hide file tree
Showing 91 changed files with 1,120 additions and 788 deletions.
15 changes: 10 additions & 5 deletions src/Domain.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <cstdint>

Expand Down Expand Up @@ -93,7 +94,9 @@ void Domain::readXML(XMLfileUnits& xmlconfig) {
<< _globalLength[2] << std::endl;
}
else {
Log::global_log->error() << "Unsupported volume type " << type << std::endl;
std::ostringstream error_message;
error_message << "Unsupported volume type " << type << std::endl;
MARDYN_EXIT(error_message);
}
xmlconfig.changecurrentnode("..");
}
Expand Down Expand Up @@ -552,8 +555,9 @@ void Domain::writeCheckpointHeader(std::string filename,
mixingss << "\t";
}
} else {
Log::global_log->error() << "Only LB mixing rule supported" << std::endl;
MARDYN_EXIT(123);
std::ostringstream error_message;
error_message << "Only LB mixing rule supported" << std::endl;
MARDYN_EXIT(error_message);
}
}
}
Expand Down Expand Up @@ -710,8 +714,9 @@ void Domain::enableComponentwiseThermostat()

void Domain::setComponentThermostat(int cid, int thermostat) {
if ((0 > cid) || (0 >= thermostat)) {
Log::global_log->error() << "Domain::setComponentThermostat: cid or thermostat id too low" << std::endl;
MARDYN_EXIT(787);
std::ostringstream error_message;
error_message << "Domain::setComponentThermostat: cid or thermostat id too low" << std::endl;
MARDYN_EXIT(error_message);
}
this->_componentToThermostatIdMap[cid] = thermostat;
this->_universalThermostatN[thermostat] = 0;
Expand Down
10 changes: 6 additions & 4 deletions src/MarDyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,20 @@ int main(int argc, char** argv) {

auto numArgs = args.size();
if(numArgs != 1) {
Log::global_log->error() << "Incorrect number of arguments provided." << std::endl;
op.print_usage();
MARDYN_EXIT(-1);
std::ostringstream error_message;
error_message << "Incorrect number of arguments provided." << std::endl;
MARDYN_EXIT(error_message);
}
/* First read the given config file if it exists, then overwrite parameters with command line arguments. */
std::string configFileName(args[0]);
if( fileExists(configFileName.c_str()) ) {
Log::global_log->info() << "Config file: " << configFileName << std::endl;
simulation.readConfigFile(configFileName);
} else {
Log::global_log->error() << "Cannot open config file '" << configFileName << "'" << std::endl;
MARDYN_EXIT(-2);
std::ostringstream error_message;
error_message << "Cannot open config file '" << configFileName << "'" << std::endl;
MARDYN_EXIT(error_message);
}

/* processing command line arguments */
Expand Down
Loading

0 comments on commit 12a8e32

Please sign in to comment.