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

refs#16

In ElemUtils:
- some changes to CustomException
parent 721b87bd
......@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.6)
project(ElementaryUtils CXX)
# Force C++98
add_definitions(-std=c++98)
add_definitions(-std=c++98 -pedantic-errors)
# Tell CMake to run moc when necessary:
set(CMAKE_AUTOMOC ON)
......
......@@ -20,8 +20,10 @@ namespace ElemUtils {
class CustomException: public std::runtime_error {
public:
CustomException(const std::string &className, const std::string &funcName,
const std::string &errorMsg);
const std::string &errorMsg) throw ();
virtual ~CustomException() throw ();
CustomException (const CustomException& other) throw ();
CustomException& operator= (const CustomException& other) throw ();
virtual const char* what() const throw ();
......
......@@ -2,8 +2,9 @@
#include <cstdio>
#include <sstream>
#include <stdexcept>
//#include <stdexcept>
#include "../../../include/ElementaryUtils/logger/CustomException.h"
#include "../../../include/ElementaryUtils/string_utils/StringUtils.h"
namespace ElemUtils {
......@@ -47,7 +48,8 @@ std::string FileUtils::read(const std::string & filePath) {
} else {
std::stringstream sstring;
sstring << "(FileUtils::read) Could not read file : " << filePath;
throw std::runtime_error(sstring.str());
// throw std::runtime_error(sstring.str());
throw CustomException("FileUtils", __func__,sstring.str());
}
return str;
......
......@@ -5,7 +5,7 @@
namespace ElemUtils {
CustomException::CustomException(const std::string &className,
const std::string &funcName, const std::string &errorMsg) :
const std::string &funcName, const std::string &errorMsg) throw () :
std::runtime_error(errorMsg), m_className(className), m_funcName(
funcName), m_errorMsg(errorMsg) {
}
......@@ -14,6 +14,21 @@ CustomException::~CustomException() throw () {
//Noting to do
}
CustomException::CustomException(const CustomException& other) throw () :
std::runtime_error(other) {
m_className = other.m_className;
m_funcName = other.m_funcName;
m_errorMsg = other.m_errorMsg;
}
CustomException& CustomException::operator =(
const CustomException& other) throw () {
m_className = other.m_className;
m_funcName = other.m_funcName;
m_errorMsg = other.m_errorMsg;
return *this;
}
const char* CustomException::what() const throw () {
ElemUtils::Formatter formatter;
formatter << "(" << m_className << "::" << m_funcName << ") " << m_errorMsg;
......
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