Merge pull request #706 from bruvzg/str_errors
commit
6a464b53f1
|
@ -32,14 +32,20 @@
|
||||||
#define GODOT_CPP_ERROR_MACROS_HPP
|
#define GODOT_CPP_ERROR_MACROS_HPP
|
||||||
|
|
||||||
#include <godot_cpp/core/defs.hpp>
|
#include <godot_cpp/core/defs.hpp>
|
||||||
|
#include <godot_cpp/variant/string.hpp>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, bool p_is_warning = false);
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, bool p_is_warning = false);
|
||||||
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, bool p_is_warning = false);
|
||||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, bool p_is_warning = false);
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, bool p_is_warning = false);
|
||||||
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const String &p_message, bool p_is_warning = false);
|
||||||
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const char *p_message, bool p_is_warning = false);
|
||||||
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const String &p_message, bool p_is_warning = false);
|
||||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message = "", bool fatal = false);
|
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message = "", bool fatal = false);
|
||||||
|
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const String &p_message, bool fatal = false);
|
||||||
|
|
||||||
// Used to strip debug messages in release mode
|
// Used to strip debug messages in release mode
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
|
|
|
@ -44,14 +44,48 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const char *p_message, bool p_is_warning) {
|
||||||
|
if (p_is_warning) {
|
||||||
|
internal::gdn_interface->print_warning(p_message, p_function, p_file, p_line);
|
||||||
|
} else {
|
||||||
|
internal::gdn_interface->print_error(p_message, p_function, p_file, p_line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const String &p_message, bool p_is_warning) {
|
||||||
|
if (p_is_warning) {
|
||||||
|
internal::gdn_interface->print_warning(p_message.utf8().get_data(), p_function, p_file, p_line);
|
||||||
|
} else {
|
||||||
|
internal::gdn_interface->print_error(p_message.utf8().get_data(), p_function, p_file, p_line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const String &p_message, bool p_is_warning) {
|
||||||
|
if (p_is_warning) {
|
||||||
|
internal::gdn_interface->print_warning(p_message.utf8().get_data(), p_function, p_file, p_line);
|
||||||
|
} else {
|
||||||
|
internal::gdn_interface->print_error(p_message.utf8().get_data(), p_function, p_file, p_line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, bool p_is_warning) {
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, bool p_is_warning) {
|
||||||
_err_print_error(p_function, p_file, p_line, "", p_error, p_is_warning);
|
_err_print_error(p_function, p_file, p_line, "", p_error, p_is_warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, bool p_is_warning) {
|
||||||
|
_err_print_error(p_function, p_file, p_line, "", p_error, p_is_warning);
|
||||||
|
}
|
||||||
|
|
||||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message, bool fatal) {
|
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message, bool fatal) {
|
||||||
std::string fstr(fatal ? "FATAL: " : "");
|
std::string fstr(fatal ? "FATAL: " : "");
|
||||||
std::string err(fstr + "Index " + p_index_str + " = " + std::to_string(p_index) + " is out of bounds (" + p_size_str + " = " + std::to_string(p_size) + ").");
|
std::string err(fstr + "Index " + p_index_str + " = " + std::to_string(p_index) + " is out of bounds (" + p_size_str + " = " + std::to_string(p_size) + ").");
|
||||||
_err_print_error(p_function, p_file, p_line, err.c_str(), p_message);
|
_err_print_error(p_function, p_file, p_line, err.c_str(), p_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const String &p_message, bool fatal) {
|
||||||
|
std::string fstr(fatal ? "FATAL: " : "");
|
||||||
|
std::string err(fstr + "Index " + p_index_str + " = " + std::to_string(p_index) + " is out of bounds (" + p_size_str + " = " + std::to_string(p_size) + ").");
|
||||||
|
_err_print_error(p_function, p_file, p_line, err.c_str(), p_message);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace godot
|
} // namespace godot
|
||||||
|
|
Loading…
Reference in New Issue