mirror of
https://github.com/davidallendj/gdpm.git
synced 2025-12-20 03:27:02 -07:00
Updated and refactored code
- Added `doxygen` API documentation with theme - Added error-compatible logging function - Added more error codes - Added `non_copyable` function - Added test function from exporting package list - Changed how errors are handled with returns - Change `gdpm remote` API to reflect `git` - Change most functions to accept a vector of arguments instead of a single parameter - Updated `.gitignore` and `README.md` files - Fixed issue with `gdpm export` command crashing
This commit is contained in:
parent
8e82a22ebd
commit
ba23299777
14 changed files with 2950 additions and 93 deletions
|
|
@ -1,12 +1,15 @@
|
|||
|
||||
#include <fmt/core.h>
|
||||
#include <string>
|
||||
#include "log.hpp"
|
||||
|
||||
namespace gdpm::error_codes{
|
||||
enum {
|
||||
UNKNOWN = 0,
|
||||
NOT_FOUND = 1,
|
||||
|
||||
NONE = 0,
|
||||
UNKNOWN = 1,
|
||||
NOT_FOUND = 2,
|
||||
FILE_EXISTS = 3,
|
||||
HOST_UNREACHABLE = 4,
|
||||
};
|
||||
|
||||
inline std::string to_string(int error_code) {
|
||||
|
|
@ -15,7 +18,7 @@ namespace gdpm::error_codes{
|
|||
};
|
||||
|
||||
namespace gdpm{
|
||||
class error{
|
||||
class error {
|
||||
public:
|
||||
error(int code = 0, const std::string& message = "", bool print_message = false):
|
||||
m_code(code), m_message(message)
|
||||
|
|
@ -36,4 +39,17 @@ namespace gdpm{
|
|||
int m_code;
|
||||
std::string m_message;
|
||||
};
|
||||
|
||||
// Add logging function that can handle error objects
|
||||
namespace log {
|
||||
template <typename S, typename...Args>
|
||||
static constexpr void error(const gdpm::error& e){
|
||||
#if GDPM_LOG_LEVEL > 1
|
||||
vlog(
|
||||
fmt::format(GDPM_COLOR_LOG_ERROR "[ERROR {}" GDPM_COLOR_LOG_RESET, e.get_message()),
|
||||
fmt::make_format_args("" /*e.get_message()*/)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue