gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
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 303 of file exceptions.hpp.

Member Typedef Documentation

◆ description

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

Definition at line 306 of file exceptions.hpp.

Constructor & Destructor Documentation

◆ Piped_exceptions()

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

Constructor.

Definition at line 308 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 564 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().

565  {
566  if (omp_get_level()==0) // If not in an OpenMP parallel block, throw onwards
567  {
568  if (this->flag)
569  {
570  // Raise all exceptions (only the first if they are fatal)
571  for(size_t i= 0; i < std::min(exceptions.size(),maxExceptions); i++)
572  {
573  excep.raise(exceptions.at(i).first, exceptions.at(i).second);
574  }
575  // Reset
576  this->flag = false;
577  exceptions.clear();
578  }
579  }
580  else
581  {
582  #pragma omp critical (GAMBIT_exception)
583  {
584  cerr << endl << " \033[00;31;1mFATAL ERROR\033[00m" << endl << endl;
585  cerr << "GAMBIT has exited with fatal exception: Piped_exceptions::check() called inside an OpenMP block." << endl
586  << "Piped exceptions may be requested inside OpenMP blocks, but should only be checked outside the block." << endl;
587  if (this->flag)
588  {
589  cerr << "Exceptions stored: " << endl << endl;
590  for(size_t i= 0; i < std::min(exceptions.size(),maxExceptions); i++)
591  {
592  cerr << exceptions.at(i).second << endl
593  << "\nRaised at: " << exceptions.at(i).first << "." << endl << endl;
594  }
595  }
596  else cerr << "No exceptions stored." << endl;
597  #ifdef WITH_MPI
598  GMPI::Comm().Abort();
599  #else
600  abort();
601  #endif
602  }
603  }
604  }
std::vector< description > exceptions
Definition: exceptions.hpp:326
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 607 of file exceptions.cpp.

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

608  {
609  return this->flag;
610  }
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 613 of file exceptions.cpp.

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

614  {
615  if (not this->flag) return false;
616  auto it = std::find_if(exceptions.cbegin(), exceptions.cend(),
617  [&message](std::pair<std::string,std::string> const &e){ return e.second == message; });
618  return it != exceptions.cend();
619  }
std::vector< description > exceptions
Definition: exceptions.hpp:326

◆ 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 558 of file exceptions.cpp.

559  {
560  this->request(desc.first, desc.second);
561  }
void request(std::string origin, std::string message)
Request an exception.
Definition: exceptions.cpp:547

Member Data Documentation

◆ exceptions

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

Definition at line 326 of file exceptions.hpp.

◆ flag

bool Gambit::Piped_exceptions::flag
private

Definition at line 324 of file exceptions.hpp.

◆ maxExceptions

size_t Gambit::Piped_exceptions::maxExceptions
private

Definition at line 325 of file exceptions.hpp.


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