00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "freExceptions.h"
00024
00025 namespace FREE
00026 {
00027
00028 LogFileController logException(GetGeneralFREEPath()+"free_error.log", "Error log of F.R.E.E. - flexible registration evaluation engine");
00029
00033
00034
00035
00036 std::string
00037 ExceptionBase::
00038 GetFullLocation() const
00039 {
00040 std::string sLocation = "";
00041 sLocation = std::string(GetFile())+"("+std::string(GetFile())+"): "+std::string(GetLocation());
00042 return sLocation;
00043 };
00044
00045 const std::string
00046 ExceptionBase::
00047 GetExceptionTrack() const
00048 {
00049 if (m_TrackedLocations.size()<1) return "";
00050 std::string sTrack = m_TrackedLocations[0];
00051
00052 for (int index=1;index<m_TrackedLocations.size(); index++)
00053 {
00054 sTrack = sTrack+" -> "+m_TrackedLocations[index];
00055 };
00056
00057 return sTrack;
00058 };
00059
00060 void
00061 ExceptionBase::
00062 AddTrack(const std::string& sLocation)
00063 {
00064 m_TrackedLocations.push_back(sLocation);
00065 };
00066
00067 void
00068 ExceptionBase::
00069 Print(std::ostream& os, bool brief) const
00070 {
00071 itk::Indent indent(2);
00072
00073
00074 os << std::endl;
00075 os << indent << "FREE::" << this->GetNameOfClass() << " (" << this << ")\n";
00076
00077
00078 itk::Indent bodyIndent = indent.GetNextIndent();
00079
00080 std::string sLocation = this->GetLocation();
00081 if (! sLocation.empty())
00082 {
00083 os << bodyIndent << "Location: \"" << sLocation << "\" " << std::endl;
00084 }
00085
00086 if (! m_ErrorCode.empty())
00087 {
00088 os << bodyIndent << "Code: " << m_ErrorCode << std::endl;
00089 }
00090
00091 std::string sFile = this->GetFile();
00092 if (! sFile.empty())
00093 {
00094 os << bodyIndent << "File: " << sFile << std::endl;
00095 os << bodyIndent << "Line: " << GetLine() << std::endl;
00096 }
00097
00098 std::string sDescription = this->GetDescription();
00099 if (! sDescription.empty())
00100 {
00101 os << std::endl << bodyIndent << "Description: " << sDescription << std::endl;
00102 }
00103
00104 if (!brief)
00105 {
00106 if (m_TrackedLocations.size()>0)
00107 {
00108 os << bodyIndent << "Track: " << std::endl;
00109 itk::Indent trackIndent = bodyIndent.GetNextIndent();
00110
00111 for (int index=0; index<=m_TrackedLocations.size()-1; index++)
00112 {
00113 os << bodyIndent << "+ " << m_TrackedLocations[index] << std::endl;
00114 }
00115 }
00116 }
00117
00118
00119 os << indent << std::endl;
00120 }
00121
00122 ExceptionBase::
00123 ExceptionBase(const std::string& sErrorCode, const std::string& sError,
00124 const std::string& sLocation, const std::string& sFile, const unsigned int iLine)
00125 : itk::ExceptionObject(sFile,iLine, sError, sLocation)
00126 {
00127 m_TrackedLocations.push_back(sLocation);
00128 m_ErrorCode = sErrorCode;
00129 };
00130
00131 ExceptionBase::
00132 ExceptionBase(const ExceptionBase& rExcBase ): itk::ExceptionObject(rExcBase)
00133 {
00134 m_TrackedLocations.clear();
00135 for (int index=0; index<=rExcBase.m_TrackedLocations.size()-1; index++)
00136 m_TrackedLocations.push_back(rExcBase.m_TrackedLocations[index]);
00137 m_ErrorCode = rExcBase.m_ErrorCode;
00138 };
00139
00140 ExceptionBase::
00141 ~ExceptionBase() throw()
00142 {
00143 m_TrackedLocations.clear();
00144 };
00145
00146
00150
00151
00152
00153 void
00154 ControllerException::
00155 Print(std::ostream& os, bool brief) const
00156 {
00157 itk::Indent indent(2);
00158
00159
00160 os << std::endl;
00161 os << indent << "FREE::" << this->GetNameOfClass() << " (" << this << ")\n";
00162
00163 os << indent << "Controller ID:" << m_ControllerName << std::endl;
00164
00165
00166 itk::Indent nextIndent = indent.GetNextIndent();
00167
00168 std::string sLocation = this->GetLocation();
00169 if (! sLocation.empty())
00170 {
00171 os << nextIndent << "Location: " << sLocation << " " << std::endl;
00172 }
00173
00174 if (! m_ErrorCode.empty())
00175 {
00176 os << nextIndent << "Code: " << m_ErrorCode << std::endl;
00177 }
00178
00179 std::string sFile = this->GetFile();
00180 if (! sFile.empty())
00181 {
00182 os << nextIndent << "File: " << sFile << std::endl;
00183 os << nextIndent << "Line: " << GetLine() << std::endl;
00184 }
00185
00186 std::string sDescription = this->GetDescription();
00187 if (! sDescription.empty())
00188 {
00189 os << std::endl << nextIndent << "Description: " << sDescription << std::endl << std::endl;
00190 }
00191
00192 if(!brief)
00193 {
00194 if (m_TrackedLocations.size()>0)
00195 {
00196 os << nextIndent << "Track: " << std::endl;
00197 itk::Indent trackIndent = nextIndent.GetNextIndent();
00198
00199 for (int index=0; index<=m_TrackedLocations.size()-1; index++)
00200 {
00201 os << trackIndent << "+ " << m_TrackedLocations[index] << std::endl;
00202 }
00203 }
00204 }
00205
00206 os << indent << std::endl;
00207 }
00208
00209 ControllerException::
00210 ControllerException(const std::string& sOriginCode, const std::string& sControllerName,
00211 const std::string& sError, const std::string& sLocation,
00212 const std::string& sFile, const unsigned int iLine)
00213 : ExceptionBase(sOriginCode, sError, sLocation, sFile, iLine)
00214 {
00215 m_ControllerName = sControllerName;
00216 };
00217
00219 ControllerException::
00220 ControllerException( const ControllerException& rExcBase ) : ExceptionBase(rExcBase)
00221 {
00222 m_ControllerName = rExcBase.m_ControllerName;
00223 };
00224
00225 ControllerException::
00226 ~ControllerException() throw()
00227 {
00228 };
00229
00230
00234
00235
00236 ItkException::
00237 ItkException(const itk::ExceptionObject& rItkException, const std::string& sWrappingLocation)
00238 : ExceptionBase("ItkException", rItkException.what(),sWrappingLocation, rItkException.GetFile(),rItkException.GetLine())
00239 {
00240 if (sWrappingLocation.size()!=0) AddTrack(sWrappingLocation);
00241 };
00242
00243 ItkException::
00244 ItkException(const ItkException& rExcBase ) : ExceptionBase(rExcBase)
00245 {
00246 };
00247
00248 ItkException::
00249 ~ItkException() throw()
00250 {
00251 };
00252
00253
00254 }