2024-06-27 15:46:41 -03:00
|
|
|
|
#ifndef XNA_EXCEPTION_HPP
|
2024-06-22 10:11:31 -03:00
|
|
|
|
#define XNA_EXCEPTION_HPP
|
|
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <source_location>
|
2024-07-13 22:50:52 -03:00
|
|
|
|
#include <memory>
|
2024-06-22 10:11:31 -03:00
|
|
|
|
|
|
|
|
|
namespace xna {
|
2024-06-22 11:52:21 -03:00
|
|
|
|
//Structure for throwing exceptions with a message and information from the source file
|
2024-06-22 10:11:31 -03:00
|
|
|
|
struct Exception {
|
2024-06-22 11:52:21 -03:00
|
|
|
|
//Raises an exception with a message. Source file information is automatically captured.
|
2024-07-13 22:50:52 -03:00
|
|
|
|
static void Throw(std::string const& message = "", std::source_location const& location = std::source_location::current());
|
2024-06-22 10:11:31 -03:00
|
|
|
|
|
2024-07-13 22:50:52 -03:00
|
|
|
|
inline static void ThrowIfNull(std::shared_ptr<void> const& argument, std::string const& argumentName, std::source_location const& location = std::source_location::current()) {
|
|
|
|
|
ThrowIfNull(&argument, argumentName, location);
|
|
|
|
|
}
|
2024-06-22 10:11:31 -03:00
|
|
|
|
|
2024-07-13 22:50:52 -03:00
|
|
|
|
inline static void ThrowIfNull(std::unique_ptr<void> const& argument, std::string const& argumentName, std::source_location const& location = std::source_location::current()) {
|
|
|
|
|
ThrowIfNull(&argument, argumentName, location);
|
2024-06-22 10:11:31 -03:00
|
|
|
|
}
|
2024-07-06 12:20:54 -03:00
|
|
|
|
|
2024-07-13 22:50:52 -03:00
|
|
|
|
static void ThrowIfNull(void const* argument, std::string const& argumentName, std::source_location const& location = std::source_location::current());
|
|
|
|
|
|
2024-07-06 12:20:54 -03:00
|
|
|
|
inline static const std::string FAILED_TO_CREATE = "Failed to create component.";
|
|
|
|
|
inline static const std::string FAILED_TO_APPLY = "Failed to apply component.";
|
|
|
|
|
inline static const std::string FAILED_TO_MAKE_WINDOW_ASSOCIATION = "Failed to create association with window.";
|
|
|
|
|
inline static const std::string UNABLE_TO_INITIALIZE = "Unable to initialize component.";
|
|
|
|
|
inline static const std::string UNABLE_TO_BUILD_OBJECT = "Unable to build object.";
|
|
|
|
|
inline static const std::string NOT_IMPLEMENTED = "Not Implemented.";
|
|
|
|
|
inline static const std::string ARGUMENT_IS_NULL = "The argument is null or one of its values.";
|
|
|
|
|
inline static const std::string INVALID_OPERATION = "An invalid operation occurred.";
|
2024-07-13 22:50:52 -03:00
|
|
|
|
inline static const std::string BAD_XNB = "Bad xnb file";
|
|
|
|
|
inline static const std::string OUT_OF_BOUNDS = "Out of bounds.";
|
|
|
|
|
inline static const std::string END_OF_FILE = "End of file.";
|
|
|
|
|
};
|
2024-06-22 10:11:31 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|