4 // * gdcmlib is a library dedicated to reading and writing dicom files.
5 // * LGPL for the license
6 // * lightweigth as opposed to CTN or DCMTK which come bundled which try
7 // to implement the full DICOM standard (networking...). gdcmlib concentrates
8 // on reading and writing
9 // * Formats: this lib should be able to read ACR-NEMA v1 and v2, Dicom v3 (as
10 // stated in part10). [cf dcmtk/dcmdata/docs/datadict.txt]
11 // * Targeted plateforms: Un*xes and Win32/VC++6.0
15 #ifndef GDCM_EXCEPTION_H
16 #define GDCM_EXCEPTION_H
20 using namespace std; // string type lives in the std namespace on VC++
28 #define GDCM_EXPORT __declspec( dllexport )
34 * Any exception thrown in the gdcm library
36 class GDCM_EXPORT gdcmException : public exception {
45 * Builds an exception with minimal information: name of the thrower
46 * method and error message
48 * @param from name of the thrower
49 * @param error error description string
51 explicit gdcmException(const string &from, const string &error = "")
56 * virtual destructor makes this class dynamic
58 virtual ~gdcmException() {
61 /// returns error message
62 const string &getError(void) const throw() {
66 /// returns exception name string
67 operator const char *() const throw();
69 /// returns exception name string (overloads std::exception::what)
70 virtual const char *what() const throw() {
71 return (const char *) *this;
75 /// exception caught within exception class: print error message and die
76 static void fatal(const char *from) throw();
78 /// try to discover this (dynamic) class name
79 virtual string getName() const throw();
81 friend ostream& operator<<(ostream &os, const gdcmException &e);
86 /** prints exception stack on output stream
87 * @param os output stream
88 * @param e exception to print
89 * @returns output stream os
91 ostream& operator<<(ostream &os, const gdcmException &e);
95 * File error exception thrown in the gdcm library
97 class GDCM_EXPORT gdcmFileError : public gdcmException {
100 * Builds an file-related exception with minimal information: name of
101 * the thrower method and error message
103 * @param from name of the thrower
104 * @param error error description string
106 explicit gdcmFileError(const string &from,
107 const string &error = "File error")
108 throw() : gdcmException(from, error) {
116 * Invalid file format exception
118 class GDCM_EXPORT gdcmFormatError : public gdcmException {
121 * Builds an file-related exception with minimal information: name of
122 * the thrower method and error message
124 * @param from name of the thrower
125 * @param error error description string
127 explicit gdcmFormatError(const string &from,
128 const string &error = "Invalid file format error")
129 throw() : gdcmException(from, error) {
134 #endif // GDCM_EXCEPTION_H