<commit_before>#include "ErrorHandler.hpp"

namespace aube
{
	ErrorMessage::ErrorMessage(std::string file, std::vector<std::string> location, std::string message, std::vector<std::string> hints)
	{
		m_file = file;
		m_location = location;
		m_message = message;
		m_hints = hints;
	}

	std::string ErrorMessage::getFile() const
	{
		return m_file;
	}

	std::string ErrorMessage::getLocation()
	{
		std::string stringLocation = m_location[0];
		for (int i = 1; i < m_location.size(); i++)
		{
			stringLocation += "::" + m_location[i];
		}
		return stringLocation;
	}

	std::string ErrorMessage::getMessage() const
	{
		return m_message;
	}

	std::vector<std::string> ErrorMessage::getHints() const
	{
		return m_hints;
	}

	std::map<std::string, ErrorMessage*> ErrorHandler::m_errors = std::map<std::string, ErrorMessage*>();
	void ErrorHandler::Load(std::string errorId, std::string filename, std::vector<std::string> location, std::string message, std::vector<std::string> hints)
	{
		m_errors[errorId] = new ErrorMessage(filename, location, message, hints);
	}

	std::exception ErrorHandler::Raise(std::string errorId, std::map<std::string, std::string> parameters)
	{
		ErrorMessage* currentError = m_errors[errorId];
		std::string errorMessage = "[" + errorId + "]{" + currentError->getFile() + "}";
		errorMessage += "<" + currentError->getLocation() + "> : " + currentError->getMessage();
		for (std::pair<std::string, std::string> parameter : parameters)
		{
			errorMessage = errorMessage.replace(errorMessage.find("%" + parameter.first + "%"), parameter.first.size() + 2, parameter.second);
		}
		std::cerr << errorMessage << std::endl;
		for (std::string& hint : currentError->getHints())
		{
			std::cerr << "    > " << hint << std::endl;
		}
		return std::exception(errorMessage.c_str());
	}
}
<commit_msg>Added default error on Aube<commit_after>#include "ErrorHandler.hpp"

namespace aube
{
	ErrorMessage::ErrorMessage(std::string file, std::vector<std::string> location, std::string message, std::vector<std::string> hints)
	{
		m_file = file;
		m_location = location;
		m_message = message;
		m_hints = hints;
	}

	std::string ErrorMessage::getFile() const
	{
		return m_file;
	}

	std::string ErrorMessage::getLocation()
	{
		std::string stringLocation = m_location[0];
		for (int i = 1; i < m_location.size(); i++)
		{
			stringLocation += "::" + m_location[i];
		}
		return stringLocation;
	}

	std::string ErrorMessage::getMessage() const
	{
		return m_message;
	}

	std::vector<std::string> ErrorMessage::getHints() const
	{
		return m_hints;
	}

	std::map<std::string, ErrorMessage*> ErrorHandler::m_errors = std::map<std::string, ErrorMessage*>();
	void ErrorHandler::Load(std::string errorId, std::string filename, std::vector<std::string> location, std::string message, std::vector<std::string> hints)
	{
		m_errors[errorId] = new ErrorMessage(filename, location, message, hints);
	}

	std::exception ErrorHandler::Raise(std::string errorId, std::map<std::string, std::string> parameters)
	{
		if (m_errors.find(errorId) != m_errors.end())
		{
			ErrorMessage* currentError = m_errors[errorId];
			std::string errorMessage = "[" + errorId + "]{" + currentError->getFile() + "}";
			errorMessage += "<" + currentError->getLocation() + "> : " + currentError->getMessage();
			for (std::pair<std::string, std::string> parameter : parameters)
			{
				errorMessage = errorMessage.replace(errorMessage.find("%" + parameter.first + "%"), parameter.first.size() + 2, parameter.second);
			}
			std::cerr << errorMessage << std::endl;
			for (std::string& hint : currentError->getHints())
			{
				std::cerr << "    > " << hint << std::endl;
			}
			return std::exception(errorMessage.c_str());
		}
		std::cerr << "Raised Unknown Exception : " << errorId << " with parameters : " << std::endl;
		for (std::pair<std::string, std::string> parameter : parameters)
		{
			std::cerr << "    > " << parameter.first << " = " << parameter.second << std::endl;
		}
		return std::exception(errorId.c_str());
	}
}

{'fraction_non_alphanumeric': 0.17802088513177525, 'fraction_numerical': 0.0014917951268025858, 'mean_word_length': 5.160796324655436, 'pattern_counts': {'":': 2, '<': 64, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4426486', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1331, 'n_words': 250}