Commit babec0ec authored by Nabil Chouika's avatar Nabil Chouika
Browse files

refs#16

In ElemUtils:
- Fix CustomException to avoid random error message due to string object being destroyed in the what() method.
parent d7f387e5
#include "../../../include/ElementaryUtils/logger/CustomException.h"
#include <cstring>
#include "../../../include/ElementaryUtils/string_utils/Formatter.h"
namespace ElemUtils {
......@@ -32,7 +34,9 @@ CustomException& CustomException::operator =(
const char* CustomException::what() const throw () {
ElemUtils::Formatter formatter;
formatter << "(" << m_className << "::" << m_funcName << ") " << m_errorMsg;
return formatter.str().c_str();
char * cstr = new char [formatter.str().length()+1];
std::strcpy (cstr, formatter.str().c_str());
return cstr;
}
const std::string& CustomException::getClassName() const {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment