次のコードがあります。
#include <exception>
class Exception : public std::exception {
private:
const char* MESSAGE = "Exception"
public:
inline virtual const char* what() const throw() {
return this->MESSAGE;
}
};
class ShoulderROMException : public Exception {
private:
typedef Exception super;
const char* MESSAGE = "ShoulderROM exception";
protected:
static const int MAX_MESSAGE_LENGTH = 200;
mutable char composedMessage[ShoulderROMException::MAX_MESSAGE_LENGTH];
public:
virtual const char* what() const throw() {
strcpy(this->composedMessage, super::what());
strcat(this->composedMessage, " -> ");
strcat(this->composedMessage, this->MESSAGE);
return this->composedMessage;
}
};
class KinectInitFailedException : public ShoulderROMException {
private:
typedef ShoulderROMException super;
const char* MESSAGE = "Kinect initialization failed."
public:
virtual const char* what() const throw() {
strcpy(this->composedMessage, super::what());
strcat(this->composedMessage, " -> ");
strcat(this->composedMessage, this->MESSAGE);
return this->composedMessage;
}
};
これにより、次のようなログ エントリが生成
されますException -> ShoulderROM exception -> Kinect initialization failed.
。
誰かがここで私を助けてくれたら、本当にいいですね。:)
よろしく、リロ