CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
cms::Exception Class Reference

#include <Exception.h>

Inheritance diagram for cms::Exception:
Clustering1DException cond::persistency::Exception DetLayerException edm::eventsetup::MakeDataException edm::eventsetup::NoDataExceptionBase edm::eventsetup::NoRecordException< T > edm::Exception edm::MultipleException edm::ProductDeletedException edmNew::CapacityExaustedException LinPtException MeasurementDetException npstat::NpstatException popcon::Exception PropagationException RPCException StatisticsException StripClusterizerAlgorithm::InvalidChargeException TrajectoryStateException VertexException

Public Member Functions

void addAdditionalInfo (char const *info)
 
void addAdditionalInfo (std::string const &info)
 
void addContext (char const *context)
 
void addContext (std::string const &context)
 
std::list< std::string > const & additionalInfo () const
 
bool alreadyPrinted () const
 
void append (char const *more_information)
 
void append (Exception const &another)
 
void append (std::string const &more_information)
 
std::string const & category () const
 
void clearAdditionalInfo ()
 
void clearContext ()
 
void clearMessage ()
 
virtual Exceptionclone () const
 
std::list< std::string > const & context () const
 
 Exception (char const *aCategory)
 
 Exception (char const *aCategory, char const *message)
 
 Exception (char const *aCategory, std::string const &message)
 
 Exception (Exception const &other)
 
 Exception (std::string const &aCategory)
 
 Exception (std::string const &aCategory, char const *message)
 
 Exception (std::string const &aCategory, std::string const &message)
 
 Exception (std::string const &aCategory, std::string const &message, Exception const &another)
 
virtual std::string explainSelf () const
 
std::list< std::string > history () const
 
std::string message () const
 
Exceptionoperator= (Exception const &other)
 
void raise ()
 
int returnCode () const
 
void setAdditionalInfo (std::list< std::string > const &info)
 
void setAlreadyPrinted (bool value)
 
void setContext (std::list< std::string > const &context)
 
void swap (Exception &other)
 
char const * what () const noexcept override
 
 ~Exception () noexcept override
 

Private Member Functions

void init (std::string const &message)
 
virtual void rethrow ()
 
virtual int returnCode_ () const
 

Private Attributes

std::list< std::string > additionalInfo_
 
bool alreadyPrinted_
 
std::string category_
 
std::list< std::string > context_
 
std::ostringstream ost_
 
std::string what_
 

Friends

template<typename E >
detail::Desired< E, detail::is_derived_or_same< Exception, std::remove_reference_t< E > >::value >::typeoperator<< (E &&e, std::ios_base &(*f)(std::ios_base &))
 
template<typename E >
detail::Desired< E, detail::is_derived_or_same< Exception, std::remove_reference_t< E > >::value >::typeoperator<< (E &&e, std::ostream &(*f)(std::ostream &))
 
template<typename E , typename T >
detail::Desired< E, detail::is_derived_or_same< Exception, std::remove_reference_t< E > >::value >::typeoperator<< (E &&e, T const &stuff)
 

Detailed Description

Definition at line 70 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception() [1/8]

Exception::Exception ( std::string const &  aCategory)
explicit

Definition at line 6 of file Exception.cc.

7  : std::exception(), ost_(), category_(aCategory), what_(), context_(), additionalInfo_(), alreadyPrinted_(false) {}

Referenced by clone().

◆ Exception() [2/8]

Exception::Exception ( char const *  aCategory)
explicit

Definition at line 9 of file Exception.cc.

10  : std::exception(),
11  ost_(),
12  category_(std::string(aCategory)),
13  what_(),
14  context_(),
16  alreadyPrinted_(false) {}

◆ Exception() [3/8]

Exception::Exception ( std::string const &  aCategory,
std::string const &  message 
)

Definition at line 18 of file Exception.cc.

19  : std::exception(), ost_(), category_(aCategory), what_(), context_(), additionalInfo_(), alreadyPrinted_(false) {
20  init(message);
21  }

References init(), and message().

◆ Exception() [4/8]

Exception::Exception ( char const *  aCategory,
std::string const &  message 
)

Definition at line 23 of file Exception.cc.

24  : std::exception(),
25  ost_(),
26  category_(std::string(aCategory)),
27  what_(),
28  context_(),
30  alreadyPrinted_(false) {
31  init(message);
32  }

References init(), and message().

◆ Exception() [5/8]

Exception::Exception ( std::string const &  aCategory,
char const *  message 
)

Definition at line 34 of file Exception.cc.

35  : std::exception(), ost_(), category_(aCategory), what_(), context_(), additionalInfo_(), alreadyPrinted_(false) {
37  }

References init(), message(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ Exception() [6/8]

Exception::Exception ( char const *  aCategory,
char const *  message 
)

Definition at line 39 of file Exception.cc.

40  : std::exception(),
41  ost_(),
42  category_(std::string(aCategory)),
43  what_(),
44  context_(),
46  alreadyPrinted_(false) {
48  }

References init(), message(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ Exception() [7/8]

Exception::Exception ( std::string const &  aCategory,
std::string const &  message,
Exception const &  another 
)

Definition at line 59 of file Exception.cc.

60  : std::exception(),
61  ost_(),
62  category_(aCategory),
63  what_(),
64  context_(another.context()),
65  additionalInfo_(another.additionalInfo()),
66  alreadyPrinted_(false) {
67  ost_ << message;
68  // check for newline at end of message first
69  if (!message.empty() && message[message.size() - 1] != '\n') {
70  ost_ << "\n";
71  }
72  append(another);
73  }

References append(), message(), and ost_.

◆ Exception() [8/8]

Exception::Exception ( Exception const &  other)

Definition at line 75 of file Exception.cc.

76  : std::exception(),
77  ost_(),
78  category_(other.category_),
79  what_(other.what_),
80  context_(other.context_),
81  additionalInfo_(other.additionalInfo_),
82  alreadyPrinted_(other.alreadyPrinted_) {
83  ost_ << other.ost_.str();
84  }

References ost_, and trackingPlots::other.

◆ ~Exception()

Exception::~Exception ( )
overridenoexcept

Definition at line 86 of file Exception.cc.

86 {}

Member Function Documentation

◆ addAdditionalInfo() [1/2]

void Exception::addAdditionalInfo ( char const *  info)

Definition at line 171 of file Exception.cc.

171 { additionalInfo_.push_back(std::string(info)); }

References additionalInfo_, info(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ addAdditionalInfo() [2/2]

void Exception::addAdditionalInfo ( std::string const &  info)

◆ addContext() [1/2]

void Exception::addContext ( char const *  context)

Definition at line 167 of file Exception.cc.

167 { context_.push_back(std::string(context)); }

References context(), context_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ addContext() [2/2]

void Exception::addContext ( std::string const &  context)

Definition at line 165 of file Exception.cc.

165 { context_.push_back(context); }

References context(), and context_.

Referenced by DavixFile::abort(), edm::ThinnedAssociationsHelper::addAssociation(), edm::addContextAndPrintException(), edm::UnscheduledCallProducer::addContextToException(), edm::ProductRegistry::addElementTypesForAliases(), edm::eventsetup::ComponentFactory< T >::addTo(), edm::eventsetup::EventSetupRecordImpl::addTraceInfoToCmsException(), edm::eventsetup::EventSetupRecord::addTraceInfoToCmsException(), L1GlobalTriggerObjectMaps::algorithmResult(), L1GlobalTriggerObjectMaps::AlgorithmResult::AlgorithmResult(), CompareToObjectMapRecord::analyze(), edm::EventProcessor::beginJob(), edm::Worker::beginJob(), edm::Worker::beginStream(), LocalCacheFile::cache(), DavixStorageMaker::check(), cms::cuda::chooseDevice(), DavixFile::close(), L1GlobalTriggerObjectMaps::consistencyCheck(), edm::serviceregistry::ServicesManager::createServiceFor(), edm::Worker::endJob(), edm::Worker::endStream(), edm::Path::exceptionContext(), edm::Worker::exceptionContext(), edm::Schedule::fillModuleAndConsumesInfo(), edm::StreamSchedule::finishedPaths(), XrdFile::getActiveFile(), XrdAdaptor::RequestManager::getActiveFile(), L1GlobalTriggerObjectMaps::getCombinationsInCondition(), L1GlobalTriggerObjectMaps::ConditionsInAlgorithm::getConditionResult(), L1GlobalTriggerObjectMaps::CombinationsInCondition::getObjectIndex(), edm::eventsetup::DependentRecordImplementation< EcalMappingRcd, edm::mpl::Vector< EcalMappingElectronicsRcd > >::getRecord(), L1GlobalTriggerObjectMaps::getStartEndIndex(), fwlite::DataGetterHelper::getThinnedKeyFrom(), BareRootProductGetter::getThinnedKeyFrom(), edm::EventPrincipal::getThinnedKeyFrom(), XrdAdaptor::Source::handle(), XrdAdaptor::RequestManager::handle(), XrdAdaptor::ClientRequest::HandleResponse(), XrdAdaptor::RequestManager::OpenHandler::HandleResponseWithHosts(), edm::BranchDescription::initFromDictionary(), XrdAdaptor::RequestManager::initialize(), edm::RootInputFileSequence::initTheFile(), LocalCacheFile::LocalCacheFile(), edm::makeInput(), nowrite(), DavixFile::open(), DCacheFile::open(), XrdFile::open(), XrdAdaptor::RequestManager::OpenHandler::open(), edm::StreamerInputFile::openStreamerFile(), XrdAdaptor::RequestManager::pickSingleSource(), DavixFile::position(), DCacheFile::position(), XrdFile::position(), ConvertObjectMapRecord::produce(), DavixFile::read(), DCacheFile::read(), XrdFile::read(), edm::StreamerInputFile::readBytes(), DQMRootSource::readFile_(), DCacheFile::readv(), DavixFile::readv(), XrdFile::readv(), edm::Worker::registerThinnedAssociations(), XrdAdaptor::RequestManager::requestFailure(), DavixFile::resize(), XrdFile::resize(), edm::UnscheduledProductResolver::resolveProduct_(), edm::eventsetup::Callback< T, TReturn, TRecord, TDecorator >::runProducerAsync(), XrdStorageMaker::setDebugLevel(), edm::StreamerInputFile::skipBytes(), XrdAdaptor::RequestManager::splitClientRequest(), DCacheStorageMaker::stagein(), edm::Maker::throwConfigurationException(), throwStorageError(), edm::Maker::throwValidationException(), L1GlobalTriggerObjectMaps::updateOperandTokenVector(), edm::eventsetup::validateEventSetupParameters(), edm::validateTopLevelParameterSets(), DavixFile::write(), DCacheFile::write(), XrdFile::write(), edm::ConfigurationDescriptions::writeCfiForLabel(), and edm::RootOutputFile::writeIndexIntoFile().

◆ additionalInfo()

std::list< std::string > const & Exception::additionalInfo ( ) const

Definition at line 149 of file Exception.cc.

149 { return additionalInfo_; }

References additionalInfo_.

◆ alreadyPrinted()

bool Exception::alreadyPrinted ( ) const

Definition at line 177 of file Exception.cc.

177 { return alreadyPrinted_; }

References alreadyPrinted_.

◆ append() [1/3]

void Exception::append ( char const *  more_information)

Definition at line 157 of file Exception.cc.

157 { ost_ << more_information; }

References ost_.

Referenced by diclist.diclist::add().

◆ append() [2/3]

void Exception::append ( Exception const &  another)

◆ append() [3/3]

void Exception::append ( std::string const &  more_information)

Definition at line 155 of file Exception.cc.

155 { ost_ << more_information; }

References ost_.

Referenced by diclist.diclist::add().

◆ category()

std::string const & Exception::category ( void  ) const

◆ clearAdditionalInfo()

void Exception::clearAdditionalInfo ( )

Definition at line 163 of file Exception.cc.

163 { additionalInfo_.clear(); }

References additionalInfo_.

Referenced by XrdAdaptor::RequestManager::initialize().

◆ clearContext()

void Exception::clearContext ( )

Definition at line 161 of file Exception.cc.

161 { context_.clear(); }

References context_.

Referenced by XrdAdaptor::RequestManager::initialize().

◆ clearMessage()

void Exception::clearMessage ( )

Definition at line 159 of file Exception.cc.

159 { ost_.str(""); }

References ost_.

Referenced by XrdAdaptor::RequestManager::initialize(), and edm::StreamerInputFile::openStreamerFile().

◆ clone()

Exception * Exception::clone ( void  ) const
virtual

Reimplemented in edm::Exception, and edm::MultipleException.

Definition at line 181 of file Exception.cc.

181 { return new Exception(*this); }

References Exception().

Referenced by edm::ExceptionCollector::call(), and edm::Path::workerFinished().

◆ context()

std::list< std::string > const & Exception::context ( ) const

◆ explainSelf()

std::string Exception::explainSelf ( ) const
virtual

Definition at line 108 of file Exception.cc.

108  {
109  std::ostringstream ost;
110 
111  if (context_.empty()) {
112  ost << "An exception of category '" << category_ << "' occurred.\n";
113  } else {
114  ost << "An exception of category '" << category_ << "' occurred while\n";
115  int count = 0;
116  for (std::list<std::string>::const_reverse_iterator i = context_.rbegin(), iEnd = context_.rend(); i != iEnd;
117  ++i, ++count) {
118  ost << " [" << count << "] " << *i << "\n";
119  }
120  }
121 
122  std::string centralMessage(ost_.str());
123  if (!centralMessage.empty()) {
124  ost << "Exception Message:\n";
125  ost << centralMessage;
126  if (centralMessage[centralMessage.size() - 1] != '\n') {
127  ost << "\n";
128  }
129  }
130 
131  if (!additionalInfo_.empty()) {
132  ost << " Additional Info:\n";
133  char c = 'a';
134  for (std::list<std::string>::const_reverse_iterator i = additionalInfo_.rbegin(), iEnd = additionalInfo_.rend();
135  i != iEnd;
136  ++i, ++c) {
137  ost << " [" << c << "] " << *i << "\n";
138  }
139  }
140  return ost.str();
141  }

References additionalInfo_, HltBtagPostValidation_cff::c, category_, context_, submitPVResolutionJobs::count, mps_fire::i, ost_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edm::ExceptionCollector::call(), L1GtUtils::LogicalExpressionL1Results::initialize(), CachedTrajectory::propagate(), TrajectoryStateClosestToPoint::TrajectoryStateClosestToPoint(), and what().

◆ history()

std::list< std::string > Exception::history ( ) const

Definition at line 187 of file Exception.cc.

187  {
188  std::list<std::string> returnValue;
189  returnValue.push_back(category_);
190  return returnValue;
191  }

References category_.

◆ init()

void Exception::init ( std::string const &  message)
private

Definition at line 50 of file Exception.cc.

50  {
51  ost_ << message;
52  if (!message.empty()) {
53  unsigned sz = message.size() - 1;
54  if (message[sz] != '\n' && message[sz] != ' ')
55  ost_ << " ";
56  }
57  }

References message(), and ost_.

Referenced by edm::GeneratorFilter< HAD, DEC >::beginLuminosityBlockProduce(), edm::HadronizerFilter< HAD, DEC >::beginLuminosityBlockProduce(), and Exception().

◆ message()

std::string Exception::message ( ) const

Definition at line 145 of file Exception.cc.

145 { return ost_.str(); }

References ost_.

Referenced by append(), edm::eventsetup::NoDataExceptionBase::constructMessage(), Exception(), and init().

◆ operator=()

Exception & Exception::operator= ( Exception const &  other)

Definition at line 97 of file Exception.cc.

97  {
99  this->swap(temp);
100  return *this;
101  }

References trackingPlots::other, swap(), and groupFilesInBlocks::temp.

◆ raise()

void cms::Exception::raise ( )
inline

Definition at line 101 of file Exception.h.

101 { rethrow(); }

Referenced by HLTBTagHarvestingAnalyzer::GetNumDenumerators().

◆ rethrow()

void Exception::rethrow ( )
privatevirtual

Reimplemented in edm::Exception.

Definition at line 183 of file Exception.cc.

183 { throw *this; }

◆ returnCode()

int Exception::returnCode ( ) const

Definition at line 151 of file Exception.cc.

151 { return returnCode_(); }

References returnCode_().

Referenced by edm::addContextAndPrintException(), and edm::ExceptionCollector::call().

◆ returnCode_()

int Exception::returnCode_ ( ) const
privatevirtual

Reimplemented in edm::Exception, and edm::MultipleException.

Definition at line 185 of file Exception.cc.

185 { return 8001; }

Referenced by returnCode().

◆ setAdditionalInfo()

void Exception::setAdditionalInfo ( std::list< std::string > const &  info)

Definition at line 175 of file Exception.cc.

175 { additionalInfo_ = info; }

References additionalInfo_, and info().

◆ setAlreadyPrinted()

void Exception::setAlreadyPrinted ( bool  value)

Definition at line 179 of file Exception.cc.

179 { alreadyPrinted_ = value; }

References alreadyPrinted_, and relativeConstraints::value.

Referenced by edm::addContextAndPrintException().

◆ setContext()

void Exception::setContext ( std::list< std::string > const &  context)

Definition at line 173 of file Exception.cc.

173 { context_ = context; }

References context(), and context_.

◆ swap()

void Exception::swap ( Exception other)

Definition at line 88 of file Exception.cc.

88  {
89  ost_ << other.ost_.str();
90  category_.swap(other.category_);
91  what_.swap(other.what_);
92  context_.swap(other.context_);
93  additionalInfo_.swap(other.additionalInfo_);
94  std::swap(alreadyPrinted_, other.alreadyPrinted_);
95  }

References additionalInfo_, alreadyPrinted_, category_, context_, ost_, trackingPlots::other, std::swap(), and what_.

Referenced by operator=().

◆ what()

char const * Exception::what ( ) const
overridenoexcept

Friends And Related Function Documentation

◆ operator<< [1/3]

template<typename E >
detail::Desired<E, detail::is_derived_or_same<Exception, std::remove_reference_t<E> >::value>::type& operator<< ( E &&  e,
std::ios_base &(*)(std::ios_base &)  f 
)
friend

Definition at line 216 of file Exception.h.

216  {
217  f(e.ost_);
218  return e;
219  }

◆ operator<< [2/3]

template<typename E >
detail::Desired<E, detail::is_derived_or_same<Exception, std::remove_reference_t<E> >::value>::type& operator<< ( E &&  e,
std::ostream &(*)(std::ostream &)  f 
)
friend

Definition at line 209 of file Exception.h.

209  {
210  f(e.ost_);
211  return e;
212  }

◆ operator<< [3/3]

template<typename E , typename T >
detail::Desired<E, detail::is_derived_or_same<Exception, std::remove_reference_t<E> >::value>::type& operator<< ( E &&  e,
T const &  stuff 
)
friend

Definition at line 202 of file Exception.h.

202  {
203  e.ost_ << stuff;
204  return e;
205  }

Member Data Documentation

◆ additionalInfo_

std::list<std::string> cms::Exception::additionalInfo_
private

◆ alreadyPrinted_

bool cms::Exception::alreadyPrinted_
private

Definition at line 190 of file Exception.h.

Referenced by alreadyPrinted(), setAlreadyPrinted(), and swap().

◆ category_

std::string cms::Exception::category_
private

Definition at line 185 of file Exception.h.

Referenced by category(), explainSelf(), history(), and swap().

◆ context_

std::list<std::string> cms::Exception::context_
private

Definition at line 188 of file Exception.h.

Referenced by addContext(), clearContext(), context(), explainSelf(), setContext(), and swap().

◆ ost_

std::ostringstream cms::Exception::ost_
private

Definition at line 184 of file Exception.h.

Referenced by append(), clearMessage(), Exception(), explainSelf(), init(), message(), and swap().

◆ what_

std::string cms::Exception::what_
mutableprivate

Definition at line 187 of file Exception.h.

Referenced by swap(), and what().

cms::Exception::swap
void swap(Exception &other)
Definition: Exception.cc:88
mps_fire.i
i
Definition: mps_fire.py:428
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
cms::Exception::message
std::string message() const
Definition: Exception.cc:145
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
cms::Exception::Exception
Exception(std::string const &aCategory)
Definition: Exception.cc:6
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
trackingPlots.other
other
Definition: trackingPlots.py:1467
cms::Exception::append
void append(Exception const &another)
Definition: Exception.cc:153
cms::Exception::ost_
std::ostringstream ost_
Definition: Exception.h:184
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
cms::Exception::init
void init(std::string const &message)
Definition: Exception.cc:50
cms::Exception::context
std::list< std::string > const & context() const
Definition: Exception.cc:147
cms::Exception::rethrow
virtual void rethrow()
Definition: Exception.cc:183
cms::Exception::alreadyPrinted_
bool alreadyPrinted_
Definition: Exception.h:190
Exception
cms::Exception::category_
std::string category_
Definition: Exception.h:185
cms::Exception::what_
std::string what_
Definition: Exception.h:187
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
cms::Exception::context_
std::list< std::string > context_
Definition: Exception.h:188
cms::Exception::additionalInfo_
std::list< std::string > additionalInfo_
Definition: Exception.h:189
cms::Exception::returnCode_
virtual int returnCode_() const
Definition: Exception.cc:185
relativeConstraints.value
value
Definition: relativeConstraints.py:53
cms::Exception::explainSelf
virtual std::string explainSelf() const
Definition: Exception.cc:108
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37