Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

gdcm::FormatError Class Reference

Invalid file format exception. More...

#include <gdcmException.h>

Inheritance diagram for gdcm::FormatError:

gdcm::FormatUnexpected gdcm::Exception List of all members.

Public Member Functions

 FormatError (const std::string &from, const std::string &error="Invalid file format") throw ()
 Builds a file-related exception with minimal information: name of the thrower method and error message.

const std::string & getError () const throw ()
 returns error message

virtual std::string getName () const throw ()
 getName

virtual const char * what () const throw ()
 returns exception name string (overloads std::exception::what)

 operator const char * () const throw ()
 Exception.


Static Public Member Functions

void fatal (const char *from) throw ()
 fatal


Protected Attributes

std::string From
 error message part 1

std::string Error
 error message part 2


Friends

std::ostream & operator<< (std::ostream &os, const Exception &e)
 Exception::operator <<.


Detailed Description

Invalid file format exception.

Definition at line 121 of file gdcmException.h.


Constructor & Destructor Documentation

gdcm::FormatError::FormatError const std::string &  from,
const std::string &  error = "Invalid file format"
throw () [inline, explicit]
 

Builds a file-related exception with minimal information: name of the thrower method and error message.

Parameters:
from name of the thrower
error error description string

Definition at line 128 of file gdcmException.h.

00130               : FormatUnexpected( from, error ) { }


Member Function Documentation

void gdcm::Exception::fatal const char *  from  )  throw () [static, inherited]
 

fatal

Parameters:
from from

Definition at line 49 of file gdcmException.cxx.

00050 {
00051    try
00052    {
00053       std::cerr << "Fatal: exception received in " << from 
00054                 << " while handling exception." << std::endl;
00055       exit(-1);
00056    }
00057    catch(...)
00058    {
00059       try
00060       {
00061          std::cerr << "Fatal: exception received in Exception::fatal while handling exception."
00062                    << std::endl;
00063          exit(-1);
00064       }
00065       catch(...)
00066       {
00067          exit(-1);
00068       }
00069    }
00070 }

const std::string& gdcm::Exception::getError  )  const throw () [inline, inherited]
 

returns error message

Definition at line 57 of file gdcmException.h.

Referenced by gdcm::operator<<().

00057                                              {
00058       return Error;
00059    }

std::string gdcm::Exception::getName  )  const throw () [virtual, inherited]
 

getName

Returns:
string

Definition at line 76 of file gdcmException.cxx.

Referenced by gdcm::operator<<().

00077 {
00078    try
00079    {
00080 #if defined(__GNUC__) && 0   // GNU C++ compiler class name demangling
00081       unsigned int nested = 1, i, nb;
00082       int offset;
00083       std::string one;
00084 
00085       std::string name;
00086       std::string iname = typeid(*this).name();
00087       if(iname[0] == 'Q')
00088       {
00089          nested = iname[1] - '0';
00090          iname = std::string(iname, 2, std::string::npos);
00091       }
00092       for(i = 0; i < nested; i++)
00093       {
00094          ::sscanf(iname.c_str(), "%u%n", &nb, &offset);
00095          iname = std::string(iname, offset, std::string::npos);
00096          name += std::string(iname, 0, nb);
00097          if(i + 1 < nested) name += "::";
00098          iname = std::string(iname, nb, std::string::npos);
00099       }
00100       return name;
00101 #else           // no class name demangling
00102       std::string name = typeid(*this).name();
00103       return name;
00104 #endif
00105    }
00106    catch(...) 
00107    {
00108       fatal("Exception::getName(std::string &)");
00109       return "";
00110    }
00111 }

gdcm::Exception::operator const char *  )  const throw () [inherited]
 

Exception.

Definition at line 116 of file gdcmException.cxx.

00117 {
00118    return getName().c_str();
00119 }

virtual const char* gdcm::Exception::what  )  const throw () [inline, virtual, inherited]
 

returns exception name string (overloads std::exception::what)

Definition at line 65 of file gdcmException.h.

00065                                             {
00066       return (const char *) *this;
00067    }


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  os,
const Exception e
[friend, inherited]
 

Exception::operator <<.

Parameters:
os ostream to write to
e exception to raise

Definition at line 127 of file gdcmException.cxx.

00128 {
00129    try 
00130    {
00131       os << "Exception " << e.getName() << " thrown: " << e.getError() << std::endl;
00132    }
00133    catch(...) 
00134    {
00135       Exception::fatal("operator<<(std::ostream &, const Exception&)");
00136    }
00137    return os;
00138 }


Member Data Documentation

std::string gdcm::Exception::Error [protected, inherited]
 

error message part 2

Definition at line 78 of file gdcmException.h.

std::string gdcm::Exception::From [protected, inherited]
 

error message part 1

Definition at line 76 of file gdcmException.h.


The documentation for this class was generated from the following file:
Generated on Thu Feb 10 22:18:09 2005 for gdcm by doxygen 1.3.6