Skip to content

Commit

Permalink
Adding error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Apr 25, 2024
1 parent 7733b42 commit e744184
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/NDItk/MultigroupTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// system includes

// other includes
#include "tools/Log.hpp"
#include "NDItk/multigroup/Metadata.hpp"
#include "NDItk/multigroup/Structure.hpp"
#include "NDItk/multigroup/FluxWeights.hpp"
Expand Down
27 changes: 20 additions & 7 deletions src/NDItk/MultigroupTable/src/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ void read( Iterator& iter, const Iterator& end ) {

if ( this->metadata_.numberGroups().has_value() ) {

readRecord( this->structure_, iter, end, this->metadata_.numberGroups().value() + 1 );
readRecord( this->structure_, iter, end,
this->metadata_.numberGroups().value() + 1 );
}
else {

throw std::runtime_error( "Required metadata is missing: number of groups in the primary group structure" );
Log::error( "Metadata required for the \'\' record was not found", keyword );
Log::info( "Required metadata is missing: number of groups in the primary group structure" );
throw std::exception();
}
}
else if ( keyword == this->weights_.keyword() ) {
Expand All @@ -34,7 +37,9 @@ void read( Iterator& iter, const Iterator& end ) {
}
else {

throw std::runtime_error( "Required metadata is missing: number of groups in the primary group structure" );
Log::error( "Metadata required for the \'\' record was not found", keyword );
Log::info( "Required metadata is missing: number of groups in the primary group structure" );
throw std::exception();
}
}
else if ( keyword == this->xs_.keyword() ) {
Expand All @@ -45,16 +50,24 @@ void read( Iterator& iter, const Iterator& end ) {
}
else {

throw std::runtime_error( "Required metadata is missing:\n"
" - number of groups in the primary group structure\n"
" - number of reactions defined in the table" );
Log::error( "Metadata required for the \'\' record was not found", keyword );
if ( ! this->metadata_.numberGroups().has_value() ) {

Log::info( "Required metadata is missing: number of groups in the primary group structure" );
}
if ( ! this->metadata_.numberReactions().has_value() ) {

Log::info( "Required metadata is missing: number of reactions" );
}
throw std::exception();
}
}
else {

if ( keyword != "end" ) {

throw std::runtime_error( std::string( "Unknown keyword: " ) + keyword );
Log::error( "Unknown keyword found: \'{}\'", keyword );
throw std::exception();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/NDItk/MultigroupTable/src/readRecord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ static void readRecord( Record& record, Iterator& iter, const Iterator& end,

if ( ! record.empty() ) {

throw std::runtime_error( std::string( "Duplicate keyword detected: " ) + record.keyword() );
Log::error( "Duplicate keyword found: \'{}\'", record.keyword() );
throw std::exception();
}
record.read( iter, end, arguments... );
}
10 changes: 9 additions & 1 deletion src/NDItk/multigroup/CrossSection/src/generateData.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
static std::vector< double > generateData( int reaction, double qvalue, std::vector< double > values ) {
/**
* @brief Generate the subrecord's data vector
*
* @param[in] reaction the reaction identifier
* @param[in] qvalue the reaction Q value
* @param[in] values the cross section values
*/
static std::vector< double >
generateData( int reaction, double qvalue, std::vector< double > values ) {

std::vector< double > data( std::move( values ) );
data.insert( data.begin(), qvalue );
Expand Down
5 changes: 4 additions & 1 deletion src/NDItk/multigroup/Metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// system includes

// other includes
#include "tools/Log.hpp"
#include "NDItk/base/SingleIntegerRecord.hpp"
#include "NDItk/base/SingleRealRecord.hpp"
#include "NDItk/base/SingleStringRecord.hpp"
Expand Down Expand Up @@ -124,7 +125,9 @@ class Metadata {
else if ( keyword == this->reactions_.keyword() ) { readRecord( this->reactions_, iter, end ); }
else {

throw std::runtime_error( "Unknown keyword" );
Log::error( "Record with keyword \'{}\' is not part of the "
"multigroup metadata", keyword );
throw std::exception();
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/NDItk/multigroup/Metadata/src/readRecord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ static void readRecord( Record& record, Iterator& iter, const Iterator& end ) {

if ( ! record.empty() ) {

throw std::runtime_error( std::string( "Duplicate keyword detected: " ) + record.keyword() );
Log::error( "Duplicate keyword found: \'{}\'", record.keyword() );
throw std::exception();
}
record.read( iter, end );
}
4 changes: 3 additions & 1 deletion src/NDItk/multigroup/ReactionCrossSections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <iostream>

// other includes
#include "tools/Log.hpp"
#include "NDItk/base/RealListRecord.hpp"
#include "NDItk/multigroup/CrossSection.hpp"

Expand Down Expand Up @@ -92,7 +93,8 @@ class ReactionCrossSections : protected base::RealListRecord {
}
else {

throw std::runtime_error( "reaction not defined" );
Log::error( "Reaction with identifier \'{}\' is not present", reaction );
throw std::exception();
}
}

Expand Down

0 comments on commit e744184

Please sign in to comment.