EMAN2
Public Member Functions | Protected Attributes | List of all members
EMAN::E2Exception Class Reference

E2Exception class is the parent class of all EMAN2 E2Exceptions. More...

#include <exception.h>

Inheritance diagram for EMAN::E2Exception:
Inheritance graph
[legend]
Collaboration diagram for EMAN::E2Exception:
Collaboration graph
[legend]

Public Member Functions

 E2Exception (const string &file="", int line=0, const string &desc_str="", const string &objname_str="")
 Contructor. More...
 
virtual ~E2Exception () throw ()
 
virtual const char * what () const throw ()
 The E2Exception information. More...
 
virtual const char * name () const
 The name of this E2Exception class. More...
 

Protected Attributes

string filename
 
int linenum
 
string desc
 
string objname
 

Detailed Description

E2Exception class is the parent class of all EMAN2 E2Exceptions.

Definition at line 67 of file exception.h.

Constructor & Destructor Documentation

◆ E2Exception()

EMAN::E2Exception::E2Exception ( const string &  file = "",
int  line = 0,
const string &  desc_str = "",
const string &  objname_str = "" 
)
inlineexplicit

Contructor.

Parameters
fileThe name of the file where an E2Exception is thrown.
lineThe line number in the file where the E2Exception is thrown.
desc_strE2Exception description string.
objname_strE2Exception involved object name.

Definition at line 77 of file exception.h.

79 : filename(file), linenum(line), desc(desc_str), objname(objname_str)
80 {
81 // Log the message
82 stringstream ss;
83 string line_str;
84 ss << line;
85 ss >> line_str;
86// We shouldn't log all exceptions, since they are frequently used intentionally, with no implied error
87// string message = "File " + file + " line " + line_str + " description " + desc_str + " " + objname_str;
88// LOGERR( message.c_str() );
89 }

◆ ~E2Exception()

virtual EMAN::E2Exception::~E2Exception ( )
throw (
)
inlinevirtual

Definition at line 91 of file exception.h.

91{}

Member Function Documentation

◆ name()

virtual const char * EMAN::E2Exception::name ( ) const
inlinevirtual

◆ what()

const char * E2Exception::what ( ) const
throw (
)
virtual

The E2Exception information.

Returns
The E2Exception information including E2Exception location (filename, line number,function name) and description.

Definition at line 36 of file exception.cpp.

37{
38 string err1 = "";
39 if (objname != "") {
40 err1 = "error with '" + objname + "': ";
41 }
42
43 string msg = string(name()) + " at " + filename + ":" + Util::int2str(linenum);
44 msg += ": " + err1 + "'" + desc + "' caught\n";
45 return msg.c_str();
46}
virtual const char * name() const
The name of this E2Exception class.
Definition: exception.h:103
static string int2str(int n)
Get a string format of an integer, e.g.
Definition: util.cpp:315

References desc, filename, EMAN::Util::int2str(), linenum, name(), and objname.

Member Data Documentation

◆ desc

string EMAN::E2Exception::desc
protected

◆ filename

string EMAN::E2Exception::filename
protected

Definition at line 105 of file exception.h.

Referenced by what().

◆ linenum

int EMAN::E2Exception::linenum
protected

Definition at line 106 of file exception.h.

Referenced by what().

◆ objname

string EMAN::E2Exception::objname
protected

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