#ifndef CEXCEPTION_HPP
#define CEXCEPTION_HPP

#include <exception>
#include <string>
#include <sstream>
#include <boost/stacktrace.hpp>

/**
 * @file CException.hpp
 * @brief File of CException, a class to handle program exception.
 */

 /**
  * @brief Class to handle program exception.
  */
class CException : public std::exception {

private:
	// The message of the exception.
	std::string m_message;

	// The code of the exception.
	unsigned int m_code;

	// The full message of the exception.
	std::string m_fullMessage;

	/**
	 * @brief Create the full message.
	 */
	void makeFullMessage(void);

public:
	/**
	 * @brief The default constructor, build a exception with default message : "An error occurred" and the code 0.
	 */
	CException(void) noexcept;

	/**
	 * @brief The usage constructor, build a exception with a given message and the given code.
	 * @param[in] message The wanted message.
	 * @param[in] code The wanted code.
	 */
	CException(const std::string message, const unsigned int code) noexcept;

	/**
	 * @brief The destructor.
	 */
	~CException(void) noexcept;

	/**
	 * @brief Give some point about the current exception.
	 * @return char*, Ready to print string, error description.
	 */
	virtual const char* what(void) const noexcept;

	/**
	 * @brief The error code getter.
	 * @return unsigned int, The code of the error.
	 */
	unsigned int getCode(void) const noexcept;

	/**
	 * @brief The error message getter.
	 * @return std::string, The message of the error.
	 */
	std::string getMessage(void) const noexcept;

	/**
	 * @brief The error message setter.
	 * @param[in] newMessage The new error message.
	 */
	void setMessage(const std::string newMessage) noexcept;
};

#endif