00001
00002
00003 #ifndef GDCM_EXCEPTION_H
00004 #define GDCM_EXCEPTION_H
00005
00006 #include "gdcmCommon.h"
00007 #include <string>
00008 #include <iostream>
00009 #include <exception>
00010
00011
00012
00013
00014
00015 class GDCM_EXPORT gdcmException : public std::exception {
00016 public:
00017
00018
00019
00020
00021
00022
00023
00024 explicit gdcmException(const std::string &from, const std::string &error = "")
00025 throw();
00026
00027
00028
00029
00030 virtual ~gdcmException() throw() {
00031 }
00032
00033
00034 static void fatal(const char *from) throw();
00035
00036
00037 const std::string &getError(void) const throw() {
00038 return error;
00039 }
00040
00041
00042 virtual std::string getName() const throw();
00043
00044
00045 virtual const char *what() const throw() {
00046 return (const char *) *this;
00047 }
00048
00049
00050 operator const char *() const throw();
00051
00052 friend std::ostream& operator<<(std::ostream &os, const gdcmException &e);
00053
00054 protected:
00055
00056 std::string from;
00057
00058 std::string error;
00059 };
00060
00061
00062
00063
00064
00065
00066 class GDCM_EXPORT gdcmFileError : public gdcmException {
00067 public:
00068
00069
00070
00071
00072
00073
00074
00075 explicit gdcmFileError(const std::string &from,
00076 const std::string &error = "File error")
00077 throw() : gdcmException(from, error) {
00078 }
00079 };
00080
00081
00082
00083
00084
00085
00086 class GDCM_EXPORT gdcmFormatError : public gdcmException {
00087 public:
00088
00089
00090
00091
00092
00093
00094
00095 explicit gdcmFormatError(const std::string &from,
00096 const std::string &error = "Invalid file format error")
00097 throw() : gdcmException(from, error) {
00098 }
00099 };
00100
00101
00102
00103
00104
00105
00106
00107 std::ostream& operator<<(std::ostream &os, const gdcmException &e);
00108
00109
00110 #endif // GDCM_EXCEPTION_H