00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00035 #include "Exception.h"
00036
00037 namespace NIDevice
00038 {
00039 namespace Core
00040 {
00041 Exception::Exception(const std::string& desc, const std::string& src) : line(0), description(desc), source(src)
00042 {
00043
00044 }
00045
00046 Exception::Exception(const std::string& desc, const std::string& src, const char* typ, const char* fil, long lin) : line(lin), typeName(typ), description(desc), source(src), file(fil)
00047 {
00048 GetFullDescription();
00049 std::cout << GetFullDescription();
00050 }
00051
00052 Exception::Exception(const Exception& exception) : line(exception.line), typeName(exception.typeName), description(exception.description), source(exception.source), file(exception.file)
00053 {
00054
00055 }
00056
00057 Exception::~Exception() throw()
00058 {
00059
00060 }
00061
00062 void Exception::operator =(const Exception& exception)
00063 {
00064 description = exception.description;
00065 source = exception.source;
00066 file = exception.file;
00067 line = exception.line;
00068 typeName = exception.typeName;
00069 }
00070
00071 const std::string& Exception::GetFullDescription() const
00072 {
00073 if (fullDesc.empty())
00074 {
00075 std::ostringstream desc;
00076 desc << "OPENNI EXCEPTION(" << typeName << "): " << description << " in " << source;
00077
00078 if(line > 0)
00079 {
00080 desc << " at " << file << " (line " << line << ")";
00081 }
00082
00083 fullDesc = desc.str();
00084 }
00085 return fullDesc;
00086 }
00087
00088 const std::string& Exception::GetSource() const
00089 {
00090 return source;
00091 }
00092
00093 const std::string& Exception::GetFile() const
00094 {
00095 return file;
00096 }
00097
00098 long Exception::GetLine() const
00099 {
00100 return line;
00101 }
00102
00103 const std::string& Exception::GetDescription() const
00104 {
00105 return description;
00106 }
00107
00108 const char* Exception::what() const throw()
00109 {
00110 return GetFullDescription().c_str();
00111 }
00112
00113 ExceptionKinect::ExceptionKinect(const std::string& description, const std::string& source, const char* file, long line) : Exception(description, source, "ExceptionKinect", file, line)
00114 {
00115
00116 }
00117 }
00118 }