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
21 #include "gdcmCommon.h"
24 * Any exception thrown in the gdcm library
26 class GDCM_EXPORT gdcmException : public exception {
35 * Builds an exception with minimal information: name of the thrower
36 * method and error message
38 * @param from name of the thrower
39 * @param error error description string
41 explicit gdcmException(const std::string &from, const std::string &error = "")
46 * virtual destructor makes this class dynamic
48 virtual ~gdcmException() {
51 /// returns error message
52 const std::string &getError(void) const throw() {
56 /// returns exception name string
57 operator const char *() const throw();
59 /// returns exception name string (overloads std::exception::what)
60 virtual const char *what() const throw() {
61 return (const char *) *this;
65 /// exception caught within exception class: print error message and die
66 static void fatal(const char *from) throw();
68 /// try to discover this (dynamic) class name
69 virtual std::string getName() const throw();
71 friend std::ostream& operator<<(std::ostream &os, const gdcmException &e);
76 /** prints exception stack on output stream
77 * @param os output stream
78 * @param e exception to print
79 * @returns output stream os
81 std::ostream& operator<<(std::ostream &os, const gdcmException &e);
85 * File error exception thrown in the gdcm library
87 class GDCM_EXPORT gdcmFileError : public gdcmException {
90 * Builds an file-related exception with minimal information: name of
91 * the thrower method and error message
93 * @param from name of the thrower
94 * @param error error description string
96 explicit gdcmFileError(const std::string &from,
97 const std::string &error = "File error")
98 throw() : gdcmException(from, error) {
104 * Invalid file format exception
106 class GDCM_EXPORT gdcmFormatError : public gdcmException {
109 * Builds an file-related exception with minimal information: name of
110 * the thrower method and error message
112 * @param from name of the thrower
113 * @param error error description string
115 explicit gdcmFormatError(const std::string &from,
116 const std::string &error = "Invalid file format error")
117 throw() : gdcmException(from, error) {
122 #endif // GDCM_EXCEPTION_H