Skip to content
Snippets Groups Projects
Commit 80341032 authored by Martin Beseda's avatar Martin Beseda
Browse files

ENH + DEL + NEW: Exceptions rewritten as macros. Now located only in exceptions.h header.

parent 90512183
No related branches found
No related tags found
No related merge requests found
//
// Created by martin on 9/17/18.
//
#ifndef LIB4NEURO_EXCEPTIONS_H
#define LIB4NEURO_EXCEPTIONS_H
#include <stdexcept>
#include <boost/type_index.hpp> //TODO Can Boost be included here?
#ifdef L4N_DEBUG
#define ERR_MSG(msg) std::string(boost::typeindex::type_id_with_cvr<decltype(*this)>().pretty_name()) + "::" + __func__ + "(): " + msg + " (" +__FILE__ + ":" + std::to_string(__LINE__) + ")"
#else
#define ERR_MSG(msg) std::string(boost::typeindex::type_id_with_cvr<decltype(*this)>().pretty_name()) + "::" + __func__ + "(): " + msg
#endif // L4N_DEBUG
#define THROW_RUNTIME_ERROR(msg) std::runtime_error(ERR_MSG(msg)) // Errors, that can't be detected by looking at the code
#define THROW_LOGIC_ERROR(msg) std::logic_error(ERR_MSG(msg)) // Errors, that can be detected by looking at the code
#define THROW_INVALID_ARGUMENT_ERROR(msg) std::invalid_argument(ERR_MSG(msg))
#define THROW_NOT_IMPLEMENTED_ERROR(msg) std::logic_error(ERR_MSG("This function is not implemented." + msg))
#endif //LIB4NEURO_EXCEPTIONS_H
......@@ -19,7 +19,6 @@ if ("${BUILD_LIB}" STREQUAL "yes")
${LIB_TYPE}
General/ExprtkWrapper.cpp
Exception/Exceptions.cpp
)
target_include_directories(
......@@ -56,7 +55,6 @@ if ("${BUILD_LIB}" STREQUAL "yes")
DataSet/DataSet.cpp
ErrorFunction/ErrorFunctions.cpp
Solvers/DESolver.cpp
Exception/Exceptions.cpp
CSVReader/CSVReader.cpp
CrossValidator/CrossValidator.cpp
NormalizationStrategy/NormalizationStrategy.cpp
......
//
// Created by martin on 9/17/18.
//
#ifndef LIB4NEURO_EXCEPTIONS_H
#define LIB4NEURO_EXCEPTIONS_H
#include <stdexcept>
namespace lib4neuro {
/**
* Class representing an error caused by an incorrect
* input/output dimension specification
*/
class InvalidDimension : public std::runtime_error {
public:
/**
* Constructor with the general error message
*/
InvalidDimension();
/**
* Constructor with specific error message
* @param msg Specific error message
*/
explicit InvalidDimension(std::string msg);
};
//TODO implement NotImplementedException according to C++17
/**
*
*/
class NotImplementedException : public std::runtime_error {
public:
/**
*
*/
NotImplementedException();
/**
*
* @param msg
*/
explicit NotImplementedException(std::string msg);
};
class FileNotFoundException : public std::runtime_error {
public:
/**
*
*/
FileNotFoundException();
/**
*
* @param msg
*/
FileNotFoundException(std::string msg);
};
}
#endif //LIB4NEURO_EXCEPTIONS_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment