fix some error
This commit is contained in:
parent
38e3cfc6a2
commit
6d37f1b914
@ -9,7 +9,6 @@ project(
|
||||
])
|
||||
|
||||
add_project_arguments (
|
||||
'-Wall',
|
||||
'-Wpedantic',
|
||||
'-Wno-shadow',
|
||||
'-Wno-unused-but-set-variable',
|
||||
|
@ -9,7 +9,6 @@ project(
|
||||
])
|
||||
|
||||
add_project_arguments (
|
||||
'-Wall',
|
||||
'-Wpedantic',
|
||||
'-Wno-shadow',
|
||||
'-Wno-unused-but-set-variable',
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
@ -3,15 +3,20 @@
|
||||
#include <experimental/source_location>
|
||||
#include <filesystem>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#define DEF_LINE() std::to_string(std::experimental::source_location::current().line())
|
||||
#define DEF_LOCATION() std::experimental::source_location::current().file_name() + std::string(" : ") + DEF_LINE()
|
||||
#define DEF_FILE_NAME() std::experimental::source_location::current().file_name()
|
||||
|
||||
#include "hack/logger/logger.hpp"
|
||||
|
||||
namespace hack::exception
|
||||
{
|
||||
using JSON = nlohmann::json;
|
||||
|
||||
const std::string SET_LOG = "set_log";
|
||||
|
||||
template<typename JSON>
|
||||
class exception
|
||||
{
|
||||
public:
|
||||
@ -21,7 +26,7 @@ namespace hack::exception
|
||||
public:
|
||||
void message(const std::string v) noexcept { m_message = v; };
|
||||
void description(const std::string v) noexcept { m_description = v; };
|
||||
void error(const std::exception& e) noexcept { m_error = e.what(); };
|
||||
void system_error(const std::exception& e) noexcept { m_system_error = e.what(); };
|
||||
void level(const std::string& v) noexcept { m_level = v; };
|
||||
|
||||
template<typename Param>
|
||||
@ -47,6 +52,12 @@ namespace hack::exception
|
||||
error()(r);
|
||||
}
|
||||
|
||||
void commit(const std::filesystem::path file_name = DEF_FILE_NAME(), std::string line = DEF_LINE())
|
||||
{
|
||||
error("")(file_name,":", line, " : [", m_level,"] ", m_message);
|
||||
warn("")(m_location, ": ", m_description);
|
||||
}
|
||||
|
||||
public:
|
||||
enum class log_level { LOW, MID, HIGHT };
|
||||
|
||||
@ -74,7 +85,7 @@ namespace hack::exception
|
||||
{
|
||||
JSON j;
|
||||
j["description"] = m_description;
|
||||
j["system_error"] = m_error;
|
||||
j["system_error"] = m_system_error;
|
||||
j["level"] = m_level;
|
||||
j["location"] = m_location;
|
||||
j["params"] = m_params;
|
||||
@ -86,7 +97,7 @@ namespace hack::exception
|
||||
private:
|
||||
std::string m_message;
|
||||
std::string m_description;
|
||||
std::string m_error;
|
||||
std::string m_system_error;
|
||||
std::string m_location;
|
||||
std::string m_level = log_converter(log_level::LOW);
|
||||
JSON m_params;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <experimental/source_location>
|
||||
#include <string>
|
||||
|
||||
// #include "boost/type_index.hpp"
|
||||
|
||||
|
@ -36,7 +36,9 @@ headers = [
|
||||
'hack/utils/singleton.hpp',
|
||||
'hack/utils/utils.hpp',
|
||||
|
||||
'hack/view/color.hpp'
|
||||
'hack/view/color.hpp',
|
||||
|
||||
'hack/exception/exception.hpp'
|
||||
]
|
||||
|
||||
sources = []
|
||||
|
Loading…
Reference in New Issue
Block a user