00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GDCM_EXCEPTION_H
00020 #define GDCM_EXCEPTION_H
00021
00022 #include "gdcmCommon.h"
00023
00024 #include <string>
00025 #include <iostream>
00026 #include <exception>
00027
00028 namespace gdcm
00029 {
00030
00031
00035 class GDCM_EXPORT Exception : public std::exception
00036 {
00037 public:
00038
00039
00040
00041
00042
00043
00044
00045 explicit Exception(const std::string &from, const std::string &error = "")
00046 throw();
00047
00051 virtual ~Exception() throw() {};
00052
00054 static void fatal(const char *from) throw();
00055
00057 const std::string &getError() const throw() {
00058 return Error;
00059 }
00060
00062 virtual std::string getName() const throw();
00063
00065 virtual const char *what() const throw() {
00066 return (const char *) *this;
00067 }
00068
00070 operator const char *() const throw();
00071
00072 friend std::ostream &operator<<(std::ostream &os, const Exception &e);
00073
00074 protected:
00076 std::string From;
00078 std::string Error;
00079 };
00080
00081
00082
00086 class GDCM_EXPORT FileError : public Exception
00087 {
00088 public:
00095 explicit FileError(const std::string &from,
00096 const std::string &error = "File error")
00097 throw() : Exception(from, error) { }
00098 };
00099
00100
00101
00105 class GDCM_EXPORT FormatUnexpected : public Exception
00106 {
00107 public:
00112 explicit FormatUnexpected(const std::string &from,
00113 const std::string &error = "Unexpected file format")
00114 throw() : Exception( from, error ) { }
00115 };
00116
00117
00121 class GDCM_EXPORT FormatError : public FormatUnexpected
00122 {
00123 public:
00128 explicit FormatError(const std::string &from,
00129 const std::string &error = "Invalid file format")
00130 throw() : FormatUnexpected( from, error ) { }
00131 };
00132
00133
00134
00135
00136
00137
00138
00139 std::ostream& operator<<(std::ostream &os, const Exception &e);
00140
00141 }
00142
00143
00144 #endif // GDCM_EXCEPTION_H