-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <glog/logging.h> | ||
#include <limestone/logging.h> | ||
#include "logging_helper.h" | ||
|
||
#include <limestone/api/limestone_exception.h> | ||
|
||
#pragma once | ||
|
||
namespace limestone { | ||
|
||
using limestone::api::limestone_exception; | ||
using limestone::api::limestone_io_exception; | ||
|
||
inline void throw_limestone_exception(const std::string& message, const char* file, int line) { | ||
throw limestone_exception(message + " (at " + std::filesystem::path(file).filename().string() + ":" + std::to_string(line) + ")"); | ||
} | ||
|
||
inline void throw_limestone_io_exception(const std::string& message, int error_code, const char* file, int line) { | ||
throw limestone_io_exception(message + " (at " + std::filesystem::path(file).filename().string() + ":" + std::to_string(line) + ")", error_code); | ||
} | ||
|
||
inline void log_and_throw_exception(const std::string& message, const char* file, int line) { | ||
LOG_LP(ERROR) << message; | ||
throw_limestone_exception(message, file, line); | ||
} | ||
|
||
inline void log_and_throw_io_exception(const std::string& message, int error_code, const char* file, int line) { | ||
std::string full_message = limestone_io_exception::format_message(message, error_code); | ||
LOG_LP(ERROR) << full_message; | ||
throw_limestone_io_exception(message, error_code, file, line); | ||
} | ||
|
||
// NOLINTNEXTLINE | ||
#define THROW_LIMESTONE_EXCEPTION(message) throw_limestone_exception(message, __FILE__, __LINE__) | ||
|
||
// NOLINTNEXTLINE | ||
#define THROW_LIMESTONE_IO_EXCEPTION(message, error_code) throw_limestone_io_exception(message, error_code, __FILE__, __LINE__) | ||
|
||
// NOLINTNEXTLINE | ||
#define LOG_AND_THROW_EXCEPTION(message) log_and_throw_exception(message, __FILE__, __LINE__) | ||
|
||
// NOLINTNEXTLINE | ||
#define LOG_AND_THROW_IO_EXCEPTION(message, error_code) log_and_throw_io_exception(message, error_code, __FILE__, __LINE__) | ||
|
||
} // namespace limestone |