gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
Gambit::Piped_exceptions Class Reference

Gambit piped error class. More...

#include <exceptions.hpp>

Collaboration diagram for Gambit::Piped_exceptions:

Public Types

typedef std::pair< std::string, std::string > description
 

Public Member Functions

 Piped_exceptions (size_t maxExceptions)
 Constructor. More...
 
void request (std::string origin, std::string message)
 Request an exception. More...
 
void request (description desc)
 Request a piped exception. More...
 
void check (exception &excep)
 Check whether any exceptions were requested, and raise them. More...
 
bool inquire ()
 Check whether any exceptions were requested without handling them. More...
 
bool inquire (std::string)
 Check whether any exceptions with a specific message were requested, without handling them. More...
 

Private Attributes

bool flag
 
size_t maxExceptions
 
std::vector< descriptionexceptions
 

Detailed Description

Gambit piped error class.

Definition at line 275 of file exceptions.hpp.

Member Typedef Documentation

◆ description

typedef std::pair<std::string,std::string> Gambit::Piped_exceptions::description

Definition at line 278 of file exceptions.hpp.

Constructor & Destructor Documentation

◆ Piped_exceptions()

Gambit::Piped_exceptions::Piped_exceptions ( size_t  maxExceptions)
inline

Constructor.

Definition at line 280 of file exceptions.hpp.

Member Function Documentation

◆ check()

void Gambit::Piped_exceptions::check ( exception &  excep)

Check whether any exceptions were requested, and raise them.

Definition at line 544 of file exceptions.cpp.

Referenced by Gambit::DarkBit::cascadeMC_LoopManager(), Gambit::DarkBit::IC22_full(), Gambit::DarkBit::IC79SL_full(), Gambit::DarkBit::IC79WH_full(), Gambit::DarkBit::IC79WL_full(), and Gambit::ColliderBit::operateLHCLoop().

545  {
546  if (omp_get_level()==0) // If not in an OpenMP parallel block, throw onwards
547  {
548  if (this->flag)
549  {
550  // Raise all exceptions (only the first if they are fatal)
551  for(size_t i= 0; i < std::min(exceptions.size(),maxExceptions); i++)
552  {
553  excep.raise(exceptions.at(i).first, exceptions.at(i).second);
554  }
555  // Reset
556  this->flag = false;
557  exceptions.clear();
558  }
559  }
560  else
561  {
562  #pragma omp critical (GAMBIT_exception)
563  {
564  cerr << endl << " \033[00;31;1mFATAL ERROR\033[00m" << endl << endl;
565  cerr << "GAMBIT has exited with fatal exception: Piped_exceptions::check() called inside an OpenMP block." << endl
566  << "Piped exceptions may be requested inside OpenMP blocks, but should only be checked outside the block." << endl;
567  if (this->flag)
568  {
569  cerr << "Exceptions stored: " << endl << endl;
570  for(size_t i= 0; i < std::min(exceptions.size(),maxExceptions); i++)
571  {
572  cerr << exceptions.at(i).second << endl
573  << "\nRaised at: " << exceptions.at(i).first << "." << endl << endl;
574  }
575  }
576  else cerr << "No exceptions stored." << endl;
577  #ifdef WITH_MPI
578  GMPI::Comm().Abort();
579  #else
580  abort();
581  #endif
582  }
583  }
584  }
std::vector< description > exceptions
Definition: exceptions.hpp:298
Here is the caller graph for this function:

◆ inquire() [1/2]

bool Gambit::Piped_exceptions::inquire ( )

Check whether any exceptions were requested without handling them.

Definition at line 587 of file exceptions.cpp.

Referenced by Gambit::DarkBit::cascadeMC_Histograms(), Gambit::DarkBit::cascadeMC_LoopManager(), and Gambit::ColliderBit::operateLHCLoop().

588  {
589  return this->flag;
590  }
Here is the caller graph for this function:

◆ inquire() [2/2]

bool Gambit::Piped_exceptions::inquire ( std::string  message)

Check whether any exceptions with a specific message were requested, without handling them.

Definition at line 593 of file exceptions.cpp.

References Gambit::piped_errors, and Gambit::piped_warnings.

594  {
595  if (not this->flag) return false;
596  auto it = std::find_if(exceptions.cbegin(), exceptions.cend(),
597  [&message](std::pair<std::string,std::string> const &e){ return e.second == message; });
598  return it != exceptions.cend();
599  }
std::vector< description > exceptions
Definition: exceptions.hpp:298

◆ request() [1/2]

void Gambit::Piped_exceptions::request ( std::string  origin,
std::string  message 
)

◆ request() [2/2]

void Gambit::Piped_exceptions::request ( description  desc)

Request a piped exception.

Definition at line 538 of file exceptions.cpp.

539  {
540  this->request(desc.first, desc.second);
541  }
void request(std::string origin, std::string message)
Request an exception.
Definition: exceptions.cpp:527

Member Data Documentation

◆ exceptions

std::vector<description> Gambit::Piped_exceptions::exceptions
private

Definition at line 298 of file exceptions.hpp.

◆ flag

bool Gambit::Piped_exceptions::flag
private

Definition at line 296 of file exceptions.hpp.

◆ maxExceptions

size_t Gambit::Piped_exceptions::maxExceptions
private

Definition at line 297 of file exceptions.hpp.


The documentation for this class was generated from the following files: