Fix a mistake that will return an invalid pointer

This commit is contained in:
Double Sine 2019-01-15 17:19:09 +08:00
parent 0994a86b2f
commit 29d886718c
No known key found for this signature in database
GPG Key ID: 44460E4F43EA8633

View File

@ -5,13 +5,15 @@
class SystemError : public Exception {
private:
const std::error_code _ErrorCode;
const std::string _ErrorString;
public:
SystemError(const char* FileName,
int Line,
unsigned long Code,
const char* Message) noexcept :
Exception(FileName, Line, Message),
_ErrorCode(Code, std::system_category()) {}
_ErrorCode(Code, std::system_category()),
_ErrorString(_ErrorCode.message()) {}
virtual bool HasErrorCode() const noexcept override {
return true;
@ -22,7 +24,7 @@ public:
}
virtual const char* ErrorString() const noexcept override {
return _ErrorCode.message().c_str();
return _ErrorString.c_str();
}
};