6#ifndef MATF_RG_PROJECT_ERRORS_HPP
7#define MATF_RG_PROJECT_ERRORS_HPP
9#include <source_location>
22 class Error :
public std::exception {
125 std::source_location
location = std::source_location::current())
134 std::string
report()
const override;
164#define RG_GUARANTEE(expr, msg, ...) \
167 throw engine::util::EngineError(engine::util::EngineError::Type::GuaranteeViolation, std::format(msg, ##__VA_ARGS__), std::source_location::current()); \
176#define RG_SHOULD_NOT_REACH_HERE(msg, ...) \
178 throw engine::util::EngineError(engine::util::EngineError::Type::ShouldNotReachHere, std::format(msg, ##__VA_ARGS__), std::source_location::current()); \
186#define RG_UNIMPLEMENTED(msg, ...) \
188 throw engine::util::EngineError(engine::util::EngineError::Type::Unimplemented, std::format(msg, ##__VA_ARGS__), std::source_location::current()); \
197#define RG_ENGINE_ERROR(type, msg, ...) \
199 throw engine::util::EngineError(type, std::format(msg, ##__VA_ARGS__), std::source_location::current()); \
Represents an error that occurred in the engine.
Definition Errors.hpp:67
Type
The type of the engine error.
Definition Errors.hpp:72
@ ConfigurationError
The error that occurs when a configuration is invalid.
@ FileNotFound
The error that occurs when a file is not found.
@ ShouldNotReachHere
The error that occurs when a function should not reach a certain point. Use this to mark a path that ...
@ AssetLoadingError
The error that occurs when an asset loading fails.
@ OpenGLError
The error that occurs when an OpenGL error occurs.
@ ShaderCompilationError
The error that occurs when a shader compilation fails.
@ Unimplemented
The error that occurs when a function is not implemented. Use this during development to mark a funct...
@ GuaranteeViolation
The error that occurs when a guarantee is violated.
Type m_error
Definition Errors.hpp:137
EngineError(Type error_type, std::string message, std::source_location location=std::source_location::current())
Construct an EngineError.
Definition Errors.hpp:124
std::string report() const override
Get the error report.
Definition Errors.cpp:25
static std::string_view type_string(Type error)
Get the string representation of the engine error type.
Definition Errors.cpp:11
Base class for all errors.
Definition Errors.hpp:22
virtual std::string report() const
Get the error report. You can override this method in derived classes to provide a more detailed erro...
Definition Errors.hpp:54
const std::string & message() const
Get the error message.
Definition Errors.hpp:38
std::string m_message
Definition Errors.hpp:59
std::source_location location() const
Get the location of the error.
Definition Errors.hpp:46
Error(std::string message, std::source_location location=std::source_location::current())
Construct an Error.
Definition Errors.hpp:29
std::source_location m_location
Definition Errors.hpp:60
Represents an error that occurred in the user's code.
Definition Errors.hpp:152