42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#ifndef ARBUTILS_ERRORHELPERS_HPP
|
|
#define ARBUTILS_ERRORHELPERS_HPP
|
|
#if defined(__clang__)
|
|
#include <experimental/source_location>
|
|
#else
|
|
#include <source_location>
|
|
#endif
|
|
#include <sstream>
|
|
#include "Exception.hpp"
|
|
|
|
#if defined(__clang__)
|
|
namespace std {
|
|
using source_location = std::experimental::source_location;
|
|
}
|
|
#endif
|
|
|
|
namespace ArbUt {
|
|
class Exception;
|
|
|
|
/// @brief Helper class for multiple error handling
|
|
class __ErrorHelpers {
|
|
static constexpr const char* file_name(const char* path) {
|
|
const char* file = path;
|
|
while (*path != 0) {
|
|
if (*path++ == '/') {
|
|
file = path;
|
|
}
|
|
}
|
|
return file;
|
|
}
|
|
|
|
public:
|
|
/// @brief Create an error for the Ensure macro
|
|
static ArbUt::Exception CreateEnsureError(const char* exp, const std::source_location& location);
|
|
|
|
/// @brief Create an error for the Throw macro
|
|
static ArbUt::Exception CreateThrowError(const char* exp, const std::source_location& location);
|
|
};
|
|
};
|
|
|
|
#endif // ARBUTILS_ERRORHELPERS_HPP
|