CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
zmex::ZMexception Class Reference

#include <ZMexception.h>

Public Member Functions

 ZMexception (const std::string &mesg, const ZMexSeverity howBad=ZMexSEVERITYenumLAST, int icount=ZMexception::_classInfo.nextCount())
 
 ZMexception (const std::ostringstream &msg, const ZMexSeverity howBad=ZMexSEVERITYenumLAST, int icount=ZMexception::_classInfo.nextCount())
 
virtual ~ZMexception ()
 
void location (int line, const std::string file) const
 
ZMexSeverity severity () const
 
int line () const
 
std::string fileName () const
 
std::string message () const
 
int count () const
 
std::string handlerUsed () const
 
bool wasThrown () const
 
void handlerUsed (const std::string handlerName) const
 
void wasThrown (bool b) const
 
virtual std::string logMessage (const std::string optText="") const
 
virtual std::string facility () const
 
virtual std::string name () const
 
bool OKtoLog () const
 
virtual ZMexceptionclone () const
 
virtual zmex::ZMexClassInfoclassInfo () const
 
virtual ZMexAction handleMe () const
 
virtual ZMexLogResult logMe () const
 
virtual bool isDerivedFrom (const std::string, const std::string) const
 
virtual void logObject () const
 

Public Attributes

 ZMexClassStaticMethods
 

Protected Attributes

const std::string message_
 
int line_
 
std::string sourceFileName_
 
const ZMexSeverity mySeverity_
 
const int myCount_
 
std::string handlerUsed_
 
bool wasThrown_
 

Static Protected Attributes

static ZMexClassInfo _classInfo
 

Detailed Description

Definition at line 163 of file ZMexception.h.

Constructor & Destructor Documentation

◆ ZMexception() [1/2]

zmex::ZMexception::ZMexception ( const std::string &  mesg,
const ZMexSeverity  howBad = ZMexSEVERITYenumLAST,
int  icount = ZMexception::_classInfo.nextCount() 
)

◆ ZMexception() [2/2]

zmex::ZMexception::ZMexception ( const std::ostringstream &  msg,
const ZMexSeverity  howBad = ZMexSEVERITYenumLAST,
int  icount = ZMexception::_classInfo.nextCount() 
)
explicit

Definition at line 199 of file ZMexception.cc.

203 :
204 message_(msg.str())
205, line_( 0 )
206, sourceFileName_( "not ZMthrow'n as of yet" )
207, mySeverity_( howBad == ZMexSEVERITYenumLAST ? _classInfo.severity() : howBad )
208, myCount_( icount )
209, wasThrown_( false )
210{ }
ZMexSeverity severity() const
static ZMexClassInfo _classInfo
Definition: ZMexception.h:166
std::string sourceFileName_
Definition: ZMexception.h:181
const ZMexSeverity mySeverity_
Definition: ZMexception.h:185
const int myCount_
Definition: ZMexception.h:186
const std::string message_
Definition: ZMexception.h:169
@ ZMexSEVERITYenumLAST
Definition: ZMexSeverity.h:66

◆ ~ZMexception()

virtual zmex::ZMexception::~ZMexception ( )
inlinevirtual

Definition at line 216 of file ZMexception.h.

216{}

Member Function Documentation

◆ classInfo()

virtual zmex::ZMexClassInfo & zmex::ZMexception::classInfo ( ) const
inlinevirtual

Definition at line 443 of file ZMexception.h.

443 {
445 }

Referenced by facility(), handleMe(), logMe(), logMessage(), and name().

◆ clone()

virtual ZMexception * zmex::ZMexception::clone ( ) const
inlinevirtual

Definition at line 439 of file ZMexception.h.

439 {
440 return new ZMexception ( *this );
441 }
ZMexception(const std::string &mesg, const ZMexSeverity howBad=ZMexSEVERITYenumLAST, int icount=ZMexception::_classInfo.nextCount())

Referenced by zmex::ZMerrnoList::write().

◆ count()

int zmex::ZMexception::count ( ) const

Referenced by logMessage().

◆ facility()

std::string zmex::ZMexception::facility ( ) const
virtual

Definition at line 95 of file ZMexception.cc.

95 {
96
97 return classInfo().facility();
98
99} // ZMexception::facility()
const std::string facility() const
virtual zmex::ZMexClassInfo & classInfo() const
Definition: ZMexception.h:443

Referenced by logMessage().

◆ fileName()

std::string zmex::ZMexception::fileName ( ) const

Referenced by logMessage().

◆ handleMe()

virtual ZMexAction zmex::ZMexception::handleMe ( ) const
inlinevirtual

Definition at line 447 of file ZMexception.h.

447 {
448 // DEBUG std::cerr << "ZMexception::handleMe()" << std::endl;
449 return ZMexception::classInfo().getHandler().takeCareOf( *this );
450 }
ZMexHandler getHandler() const
virtual ZMexAction takeCareOf(const ZMexception &x)
Definition: ZMexHandler.h:112

Referenced by zmex::ZMthrow_().

◆ handlerUsed() [1/2]

std::string zmex::ZMexception::handlerUsed ( ) const

◆ handlerUsed() [2/2]

void zmex::ZMexception::handlerUsed ( const std::string  handlerName) const

◆ isDerivedFrom()

virtual bool zmex::ZMexception::isDerivedFrom ( const std::string  ,
const std::string   
) const
inlinevirtual

Definition at line 457 of file ZMexception.h.

460 {
461 return false;
462 }

◆ line()

int zmex::ZMexception::line ( ) const

Referenced by logMessage().

◆ location()

void zmex::ZMexception::location ( int  line,
const std::string  file 
) const

Referenced by zmex::ZMthrow_().

◆ logMe()

virtual ZMexLogResult zmex::ZMexception::logMe ( ) const
inlinevirtual

Definition at line 452 of file ZMexception.h.

452 {
453 // DEBUG std::cerr << "ZMexception::logMe()" << std::endl;
454 return ZMexception::classInfo().getLogger().emit(*this);
455 }
ZMexLogger getLogger() const
ZMexLogResult emit(const ZMexception &exc)
Definition: ZMexLogger.cc:255

Referenced by zmex::ZMexHandlerBehavior::standardHandling().

◆ logMessage()

std::string zmex::ZMexception::logMessage ( const std::string  optText = "") const
virtual

Definition at line 122 of file ZMexception.cc.

122 {
123
124 std::ostringstream mesg;
125
126 // define how each follow-on line should begin:
127 #define NEXT "\n "
128
129 // Supply the exception's identification as the first line:
130 mesg << facility()
131 << "-" << ZMexSeverityLetter[ severity() ]
132 << "-" << name() << " [#" << count() << "]";
133
134 // Second line gives the exception instance's message
135 mesg << NEXT << message();
136
137 // Warn if this exception hits the max for its severity:
138 if ( 1 == ZMexSeverityLimit[ severity() ] )
139 mesg << NEXT "-- Note: severity threshhold has been reached; "
140 "logging will be suppressed "
141 "for any future exceptions of this severity";
142
143 // Warn if this exception hits the max for its class:
144 if ( classInfo().count() == classInfo().filterMax() )
145 mesg << NEXT "-- Note: class threshhold has been reached; "
146 "logging will be suppressed "
147 "for any future exceptions of this class";
148
149 // Insert optional text (probably from override calling this as its ancestor):
150 if ( optText.length() )
151 mesg << NEXT << optText;
152
153 // Insert time stamp:
154 ZMexLogger lgr = getLogger();
155 if ( lgr.control()->isTimeDesired() ) {
156 time_t now( time(0) );
157 char * timeText = ctime( & now );
158 timeText[24] = '\0'; // overwrite terminal '\n'
159 mesg << NEXT << timeText;
160 }
161
162 // Identify whence we got here:
163 mesg << NEXT "-- ZMthrow was issued at line " << line();
164 std::string fullName = fileName();
165 std::string fname;
166 if ( lgr.control()->isFilePathDesired() ) {
167 fname = fullName;
168 } else {
169 unsigned long lastSlash = fullName.find_last_of("/\\");
170 if ( lastSlash == fullName.length() ) {
171 fname = fullName;
172 } else {
173 fname = fullName.substr(lastSlash+1);
174 }
175 }
176 mesg << NEXT "of file \"" << fname << '\"';
177
178 // Identify disposition:
179 mesg << NEXT "... Exception " << ( wasThrown() ? "thrown!"
180 : "ignored"
181 );
182
183 // Include optional user information, part 1:
184 if ( ZMexUserActivity.length() )
185 mesg << NEXT "-- ZMexUserActivity was: " << ZMexUserActivity;
186
187 // Include optional user information, part 2:
189 mesg << NEXT "-- User Numerical Tag was: " << ZMexUserNumericalTag;
190
191 return mesg.str() + '\n';
192
193} // ZMexception::logMessage()
#define NEXT
int count() const
std::string fileName() const
int line() const
std::string message() const
virtual std::string facility() const
Definition: ZMexception.cc:95
bool wasThrown() const
ZMexSeverity severity() const
virtual std::string name() const
Definition: ZMexception.cc:106
int ZMexUserNumericalTag
Definition: ZMexception.cc:56
int ZMexSeverityLimit[ZMexSEVERITYenumLAST]
Definition: ZMexSeverity.cc:45
std::string ZMexUserActivity
Definition: ZMexception.cc:55
const char ZMexSeverityLetter[ZMexSEVERITYenumLAST]
Definition: ZMexSeverity.cc:34

Referenced by zmex::ZMexLogAlways::emit(), zmex::ZMexLogTwice::emit(), and zmex::ZMexValidationStyle::emit().

◆ logObject()

virtual void zmex::ZMexception::logObject ( ) const
inlinevirtual

Definition at line 464 of file ZMexception.h.

464{} //added

Referenced by zmex::ZMexLogAlways::emit(), zmex::ZMexLogTwice::emit(), and zmex::ZMexValidationStyle::emit().

◆ message()

std::string zmex::ZMexception::message ( ) const

Referenced by display(), logMessage(), and main().

◆ name()

std::string zmex::ZMexception::name ( ) const
virtual

Definition at line 106 of file ZMexception.cc.

106 {
107
108 return classInfo().name();
109
110} // ZMexception::name()
const std::string name() const

Referenced by display(), logMessage(), main(), and zmex::ZMerrnoList::name().

◆ OKtoLog()

bool zmex::ZMexception::OKtoLog ( ) const

◆ severity()

◆ wasThrown() [1/2]

bool zmex::ZMexception::wasThrown ( ) const

◆ wasThrown() [2/2]

void zmex::ZMexception::wasThrown ( bool  b) const

Member Data Documentation

◆ _classInfo

ZMexClassInfo zmex::ZMexception::_classInfo
staticprotected

Definition at line 166 of file ZMexception.h.

Referenced by classInfo().

◆ handlerUsed_

std::string zmex::ZMexception::handlerUsed_
mutableprotected

Definition at line 190 of file ZMexception.h.

◆ line_

int zmex::ZMexception::line_
mutableprotected

Definition at line 177 of file ZMexception.h.

◆ message_

const std::string zmex::ZMexception::message_
protected

Definition at line 169 of file ZMexception.h.

◆ myCount_

const int zmex::ZMexception::myCount_
protected

Definition at line 186 of file ZMexception.h.

◆ mySeverity_

const ZMexSeverity zmex::ZMexception::mySeverity_
protected

Definition at line 185 of file ZMexception.h.

◆ sourceFileName_

std::string zmex::ZMexception::sourceFileName_
mutableprotected

Definition at line 181 of file ZMexception.h.

◆ wasThrown_

bool zmex::ZMexception::wasThrown_
mutableprotected

Definition at line 194 of file ZMexception.h.

◆ ZMexClassStaticMethods

zmex::ZMexception::ZMexClassStaticMethods

Definition at line 435 of file ZMexception.h.


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