Yerbacon/src/headers/Yerbacon.hpp

33 lines
937 B
C++
Raw Normal View History

#ifndef YERBACON_HPP
#define YERBACON_HPP
#ifndef YBCON_VERSION
#warning "YBCON_VERSION is unknown and will therefore be set to a default value"
#define YBCON_VERSION "UNKNOWN"
#endif
#ifdef __STDC_NO_THREADS__
#error "A valid std::threads implementation is required"
#endif
#include <exception>
#include <string_view>
#include <string>
#include <optional>
namespace Yerbacon {
consteval const char* getVersion() noexcept { return YBCON_VERSION; }
class Exception: public std::exception {
std::string exceptionCause;
2021-08-18 18:59:46 +02:00
public:
[[nodiscard]] const char* what() const noexcept final {
return exceptionCause.data();
}
public:
explicit Exception(const std::string_view& cause): exceptionCause(cause) {}
Exception(const std::string_view& cause, unsigned long line): exceptionCause(('L' + std::to_string(line) + ": ").append(cause)) {}
};
}
2021-08-10 15:48:26 +02:00
#undef YBCON_VERSION
#endif