Skip to content

Commit

Permalink
use adiosLog in adiosXML
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonRuonanWang committed Dec 6, 2021
1 parent a9d8ceb commit 5e59300
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
44 changes: 24 additions & 20 deletions source/adios2/helper/adiosXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "adios2/common/ADIOSTypes.h"
#include "adios2/core/IO.h"
#include "adios2/helper/adiosLog.h"
#include "adios2/helper/adiosString.h"
#include "adios2/helper/adiosXMLUtil.h"

Expand All @@ -44,8 +45,8 @@ void ParseConfigXML(

if (fileContents.empty())
{
throw std::invalid_argument("ERROR: config xml file is empty, " +
hint + "\n");
helper::Log("Helper", "AdiosXML", "ParseConfigXML",
"empty config xml file", helper::EXCEPTION);
}
return fileContents;
};
Expand Down Expand Up @@ -82,23 +83,25 @@ void ParseConfigXML(

if (*opName && *opType)
{
throw std::invalid_argument(
"ERROR: operator (" + std::string(opName->value()) +
") and type (" + std::string(opType->value()) +
") attributes can't coexist in <operation> element "
"inside <variable name=\"" +
variableName + "\"> element, " + hint + "\n");
helper::Log(
"Helper", "AdiosXML", "ParseConfigXML",
"operator (" + std::string(opName->value()) +
") and type (" + std::string(opType->value()) +
") attributes can't coexist in <operation> element "
"inside <variable name=\"" +
variableName + "\"> element",
helper::EXCEPTION);
}

if (!*opName && !*opType)
{
throw std::invalid_argument(
"ERROR: <operation> element "
"inside <variable name=\"" +
variableName +
"\"> element requires either operator "
"(existing) or type (supported) attribute, " +
hint + "\n");
helper::Log("Helper", "AdiosXML", "ParseConfigXML",
"<operation> element "
"inside <variable name=\"" +
variableName +
"\"> element requires either operator "
"(existing) or type (supported) attribute",
helper::EXCEPTION);
}

core::Operator *op = nullptr;
Expand All @@ -108,11 +111,12 @@ void ParseConfigXML(
auto itOperator = operators.find(std::string(opName->value()));
if (itOperator == operators.end())
{
throw std::invalid_argument(
"ERROR: operator " + std::string(opName->value()) +
" not previously defined, from variable " +
variableName + " inside io " + currentIO.m_Name + ", " +
hint + "\n");
helper::Log("Helper", "AdiosXML", "ParseConfigXML",
"operator " + std::string(opName->value()) +
" not previously defined, from variable " +
variableName + " inside io " +
currentIO.m_Name,
helper::EXCEPTION);
}
op = itOperator->second.get();
}
Expand Down
14 changes: 6 additions & 8 deletions testing/adios2/xml/TestXMLConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ TEST_F(XMLConfigTest, OpTypeException)
if (rank == 0)
{
EXPECT_THROW(adios2::ADIOS adios(configFile, MPI_COMM_SELF),
std::invalid_argument);
std::string);
}
#else
EXPECT_THROW(adios2::ADIOS adios(configFile), std::invalid_argument);
EXPECT_THROW(adios2::ADIOS adios(configFile), std::string);
#endif
}

Expand All @@ -106,10 +106,9 @@ TEST_F(XMLConfigTest, OpNullException)
"configOpNullException.xml");

#if ADIOS2_USE_MPI
EXPECT_THROW(adios2::ADIOS adios(configFile, MPI_COMM_WORLD),
std::invalid_argument);
EXPECT_THROW(adios2::ADIOS adios(configFile, MPI_COMM_WORLD), std::string);
#else
EXPECT_THROW(adios2::ADIOS adios(configFile), std::invalid_argument);
EXPECT_THROW(adios2::ADIOS adios(configFile), std::string);
#endif
}

Expand All @@ -120,10 +119,9 @@ TEST_F(XMLConfigTest, OpNoneException)
"configOpNoneException.xml");

#if ADIOS2_USE_MPI
EXPECT_THROW(adios2::ADIOS adios(configFile, MPI_COMM_WORLD),
std::invalid_argument);
EXPECT_THROW(adios2::ADIOS adios(configFile, MPI_COMM_WORLD), std::string);
#else
EXPECT_THROW(adios2::ADIOS adios(configFile), std::invalid_argument);
EXPECT_THROW(adios2::ADIOS adios(configFile), std::string);
#endif
}

Expand Down

0 comments on commit 5e59300

Please sign in to comment.