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
24 #define GDCM_EXPORT __declspec( dllexport )
30 * Any exception thrown in the gdcm library
32 class GDCM_EXPORT gdcmException : public exception {
41 * Builds an exception with minimal information: name of the thrower
42 * method and error message
44 * @param from name of the thrower
45 * @param error error description string
47 explicit gdcmException(const string &from, const string &error = "")
52 * virtual descructor makes this class dynamic
54 virtual ~gdcmException() {
57 /// returns error message
58 const string &getError(void) const throw() {
62 /// returns exception name string
63 operator const char *() const throw();
65 /// returns exception name string (overloads std::exception::what)
66 virtual const char *what() const throw() {
67 return (const char *) *this;
71 /// exception caught within exception class: print error message and die
72 static void fatal(const char *from) throw();
74 /// try to discover this (dynamic) class name
75 virtual string getName() const throw();
77 friend ostream& operator<<(ostream &os, const gdcmException &e);
82 /** prints exception stack on output stream
83 * @param os output stream
84 * @param e exception to print
85 * @returns output stream os
87 ostream& operator<<(ostream &os, const gdcmException &e);
91 * File error exception thrown in the gdcm library
93 class GDCM_EXPORT gdcmFileError : public gdcmException {
96 * Builds an file-related exception with minimal information: name of
97 * the thrower method and error message
99 * @param from name of the thrower
100 * @param error error description string
102 explicit gdcmFileError(const string &from,
103 const string &error = "File error")
104 throw() : gdcmException(from, error) {
112 * Invalid file format exception
114 class GDCM_EXPORT gdcmFormatError : public gdcmException {
117 * Builds an file-related exception with minimal information: name of
118 * the thrower method and error message
120 * @param from name of the thrower
121 * @param error error description string
123 explicit gdcmFormatError(const string &from,
124 const string &error = "Invalid file format error")
125 throw() : gdcmException(from, error) {
130 #endif // GDCM_EXCEPTION_H