Merge pull request #31244 from Unholydeath/BB_ChangeErrorMacros

Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in 'core/' and 'editor/'
This commit is contained in:
Rémi Verschelde 2019-08-17 13:31:08 +02:00 committed by GitHub
commit de4aabe89b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
76 changed files with 297 additions and 708 deletions

View File

@ -133,18 +133,12 @@ void Array::erase(const Variant &p_value) {
} }
Variant Array::front() const { Variant Array::front() const {
if (_p->array.size() == 0) { ERR_FAIL_COND_V_MSG(_p->array.size() == 0, Variant(), "Can't take value from empty array.");
ERR_EXPLAIN("Can't take value from empty array");
ERR_FAIL_V(Variant());
}
return operator[](0); return operator[](0);
} }
Variant Array::back() const { Variant Array::back() const {
if (_p->array.size() == 0) { ERR_FAIL_COND_V_MSG(_p->array.size() == 0, Variant(), "Can't take value from empty array.");
ERR_EXPLAIN("Can't take value from empty array");
ERR_FAIL_V(Variant());
}
return operator[](_p->array.size() - 1); return operator[](_p->array.size() - 1);
} }

View File

@ -73,10 +73,7 @@ RES _ResourceLoader::load(const String &p_path, const String &p_type_hint, bool
Error err = OK; Error err = OK;
RES ret = ResourceLoader::load(p_path, p_type_hint, p_no_cache, &err); RES ret = ResourceLoader::load(p_path, p_type_hint, p_no_cache, &err);
if (err != OK) { ERR_FAIL_COND_V_MSG(err != OK, ret, "Error loading resource: '" + p_path + "'.");
ERR_EXPLAIN("Error loading resource: '" + p_path + "'");
ERR_FAIL_V(ret);
}
return ret; return ret;
} }
@ -148,10 +145,7 @@ _ResourceLoader::_ResourceLoader() {
} }
Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) { Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) {
if (p_resource.is_null()) { ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path: " + String(p_path) + ".");
ERR_EXPLAIN("Can't save empty resource to path: " + String(p_path))
ERR_FAIL_V(ERR_INVALID_PARAMETER);
}
return ResourceSaver::save(p_path, p_resource, p_flags); return ResourceSaver::save(p_path, p_resource, p_flags);
} }
@ -727,22 +721,16 @@ int64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
}; };
ERR_EXPLAIN("Invalid second value of: " + itos(second)); ERR_FAIL_COND_V_MSG(second > 59, 0, "Invalid second value of: " + itos(second) + ".");
ERR_FAIL_COND_V(second > 59, 0);
ERR_EXPLAIN("Invalid minute value of: " + itos(minute)); ERR_FAIL_COND_V_MSG(minute > 59, 0, "Invalid minute value of: " + itos(minute) + ".");
ERR_FAIL_COND_V(minute > 59, 0);
ERR_EXPLAIN("Invalid hour value of: " + itos(hour)); ERR_FAIL_COND_V_MSG(hour > 23, 0, "Invalid hour value of: " + itos(hour) + ".");
ERR_FAIL_COND_V(hour > 23, 0);
ERR_EXPLAIN("Invalid month value of: " + itos(month)); ERR_FAIL_COND_V_MSG(month > 12 || month == 0, 0, "Invalid month value of: " + itos(month) + ".");
ERR_FAIL_COND_V(month > 12 || month == 0, 0);
// Do this check after month is tested as valid // Do this check after month is tested as valid
ERR_EXPLAIN("Invalid day value of: " + itos(day) + " which is larger than " + itos(MONTH_DAYS_TABLE[LEAPYEAR(year)][month - 1]) + " or 0"); ERR_FAIL_COND_V_MSG(day > MONTH_DAYS_TABLE[LEAPYEAR(year)][month - 1] || day == 0, 0, "Invalid day value of: " + itos(day) + " which is larger than " + itos(MONTH_DAYS_TABLE[LEAPYEAR(year)][month - 1]) + " or 0.");
ERR_FAIL_COND_V(day > MONTH_DAYS_TABLE[LEAPYEAR(year)][month - 1] || day == 0, 0);
// Calculate all the seconds from months past in this year // Calculate all the seconds from months past in this year
uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR = DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month - 1] * SECONDS_PER_DAY; uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR = DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month - 1] * SECONDS_PER_DAY;
@ -2621,8 +2609,7 @@ void _Thread::_start_func(void *ud) {
} }
} }
ERR_EXPLAIN("Could not call function '" + t->target_method.operator String() + "'' starting thread ID: " + t->get_id() + " Reason: " + reason); ERR_FAIL_MSG("Could not call function '" + t->target_method.operator String() + "'' starting thread ID: " + t->get_id() + " Reason: " + reason + ".");
ERR_FAIL();
} }
} }
@ -2704,10 +2691,7 @@ _Thread::_Thread() {
_Thread::~_Thread() { _Thread::~_Thread() {
if (active) { ERR_FAIL_COND_MSG(active, "Reference to a Thread object object was lost while the thread is still running...");
ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running...");
}
ERR_FAIL_COND(active);
} }
///////////////////////////////////// /////////////////////////////////////

View File

@ -836,10 +836,7 @@ void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) {
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
ClassInfo *check = type; ClassInfo *check = type;
while (check) { while (check) {
if (check->signal_map.has(sname)) { ERR_FAIL_COND_MSG(check->signal_map.has(sname), "Type " + String(p_class) + " already has signal: " + String(sname) + ".");
ERR_EXPLAIN("Type " + String(p_class) + " already has signal: " + String(sname));
ERR_FAIL();
}
check = check->inherits_ptr; check = check->inherits_ptr;
} }
#endif #endif
@ -924,16 +921,11 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
if (p_setter) { if (p_setter) {
mb_set = get_method(p_class, p_setter); mb_set = get_method(p_class, p_setter);
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if (!mb_set) {
ERR_EXPLAIN("Invalid Setter: " + p_class + "::" + p_setter + " for property: " + p_pinfo.name); ERR_FAIL_COND_MSG(!mb_set, "Invalid setter: " + p_class + "::" + p_setter + " for property: " + p_pinfo.name + ".");
ERR_FAIL();
} else { int exp_args = 1 + (p_index >= 0 ? 1 : 0);
int exp_args = 1 + (p_index >= 0 ? 1 : 0); ERR_FAIL_COND_MSG(mb_set->get_argument_count() != exp_args, "Invalid function for setter: " + p_class + "::" + p_setter + " for property: " + p_pinfo.name + ".");
if (mb_set->get_argument_count() != exp_args) {
ERR_EXPLAIN("Invalid Function for Setter: " + p_class + "::" + p_setter + " for property: " + p_pinfo.name);
ERR_FAIL();
}
}
#endif #endif
} }
@ -943,25 +935,15 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
mb_get = get_method(p_class, p_getter); mb_get = get_method(p_class, p_getter);
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if (!mb_get) { ERR_FAIL_COND_MSG(!mb_get, "Invalid getter: " + p_class + "::" + p_getter + " for property: " + p_pinfo.name + ".");
ERR_EXPLAIN("Invalid Getter: " + p_class + "::" + p_getter + " for property: " + p_pinfo.name);
ERR_FAIL();
} else {
int exp_args = 0 + (p_index >= 0 ? 1 : 0); int exp_args = 0 + (p_index >= 0 ? 1 : 0);
if (mb_get->get_argument_count() != exp_args) { ERR_FAIL_COND_MSG(mb_get->get_argument_count() != exp_args, "Invalid function for getter: " + p_class + "::" + p_getter + " for property: " + p_pinfo.name + ".");
ERR_EXPLAIN("Invalid Function for Getter: " + p_class + "::" + p_getter + " for property: " + p_pinfo.name);
ERR_FAIL();
}
}
#endif #endif
} }
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if (type->property_setget.has(p_pinfo.name)) { ERR_FAIL_COND_MSG(type->property_setget.has(p_pinfo.name), "Object " + p_class + " already has property: " + p_pinfo.name + ".");
ERR_EXPLAIN("Object " + p_class + " already has property: " + p_pinfo.name);
ERR_FAIL();
}
#endif #endif
OBJTYPE_WLOCK OBJTYPE_WLOCK
@ -1240,32 +1222,26 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (has_method(instance_type, mdname)) { ERR_FAIL_COND_V_MSG(has_method(instance_type, mdname), NULL, "Class " + String(instance_type) + " already has a method " + String(mdname) + ".");
ERR_EXPLAIN("Class " + String(instance_type) + " already has a method " + String(mdname));
ERR_FAIL_V(NULL);
}
#endif #endif
ClassInfo *type = classes.getptr(instance_type); ClassInfo *type = classes.getptr(instance_type);
if (!type) { if (!type) {
ERR_PRINTS("Couldn't bind method '" + mdname + "' for instance: " + instance_type);
memdelete(p_bind); memdelete(p_bind);
ERR_FAIL_V(NULL); ERR_FAIL_V_MSG(NULL, "Couldn't bind method '" + mdname + "' for instance: " + instance_type + ".");
} }
if (type->method_map.has(mdname)) { if (type->method_map.has(mdname)) {
memdelete(p_bind); memdelete(p_bind);
// overloading not supported // overloading not supported
ERR_EXPLAIN("Method already bound: " + instance_type + "::" + mdname); ERR_FAIL_V_MSG(NULL, "Method already bound: " + instance_type + "::" + mdname + ".");
ERR_FAIL_V(NULL);
} }
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
if (method_name.args.size() > p_bind->get_argument_count()) { if (method_name.args.size() > p_bind->get_argument_count()) {
memdelete(p_bind); memdelete(p_bind);
ERR_EXPLAIN("Method definition provides more arguments than the method actually has: " + instance_type + "::" + mdname); ERR_FAIL_V_MSG(NULL, "Method definition provides more arguments than the method actually has: " + instance_type + "::" + mdname + ".");
ERR_FAIL_V(NULL);
} }
p_bind->set_argument_names(method_name.args); p_bind->set_argument_names(method_name.args);

View File

@ -306,8 +306,7 @@ public:
if (type->method_map.has(p_name)) { if (type->method_map.has(p_name)) {
memdelete(bind); memdelete(bind);
// overloading not supported // overloading not supported
ERR_EXPLAIN("Method already bound: " + instance_type + "::" + p_name); ERR_FAIL_V_MSG(NULL, "Method already bound: " + instance_type + "::" + p_name + ".");
ERR_FAIL_V(NULL);
} }
type->method_map[p_name] = bind; type->method_map[p_name] = bind;
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED

View File

@ -335,36 +335,23 @@ Color Color::html(const String &p_color) {
} else if (color.length() == 6) { } else if (color.length() == 6) {
alpha = false; alpha = false;
} else { } else {
ERR_EXPLAIN("Invalid Color Code: " + p_color); ERR_FAIL_V_MSG(Color(), "Invalid color code: " + p_color + ".");
ERR_FAIL_V(Color());
} }
int a = 255; int a = 255;
if (alpha) { if (alpha) {
a = _parse_col(color, 0); a = _parse_col(color, 0);
if (a < 0) { ERR_FAIL_COND_V_MSG(a < 0, Color(), "Invalid color code: " + p_color + ".");
ERR_EXPLAIN("Invalid Color Code: " + p_color);
ERR_FAIL_V(Color());
}
} }
int from = alpha ? 2 : 0; int from = alpha ? 2 : 0;
int r = _parse_col(color, from + 0); int r = _parse_col(color, from + 0);
if (r < 0) { ERR_FAIL_COND_V_MSG(r < 0, Color(), "Invalid color code: " + p_color + ".");
ERR_EXPLAIN("Invalid Color Code: " + p_color);
ERR_FAIL_V(Color());
}
int g = _parse_col(color, from + 2); int g = _parse_col(color, from + 2);
if (g < 0) { ERR_FAIL_COND_V_MSG(g < 0, Color(), "Invalid color code: " + p_color + ".");
ERR_EXPLAIN("Invalid Color Code: " + p_color);
ERR_FAIL_V(Color());
}
int b = _parse_col(color, from + 4); int b = _parse_col(color, from + 4);
if (b < 0) { ERR_FAIL_COND_V_MSG(b < 0, Color(), "Invalid color code: " + p_color + ".");
ERR_EXPLAIN("Invalid Color Code: " + p_color);
ERR_FAIL_V(Color());
}
return Color(r / 255.0, g / 255.0, b / 255.0, a / 255.0); return Color(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
} }
@ -425,12 +412,8 @@ Color Color::named(const String &p_name) {
name = name.to_lower(); name = name.to_lower();
const Map<String, Color>::Element *color = _named_colors.find(name); const Map<String, Color>::Element *color = _named_colors.find(name);
if (color) { ERR_FAIL_NULL_V_MSG(color, Color(), "Invalid color name: " + p_name + ".");
return color->value(); return color->value();
} else {
ERR_EXPLAIN("Invalid Color Name: " + p_name);
ERR_FAIL_V(Color());
}
} }
String _to_hex(float p_val) { String _to_hex(float p_val) {
@ -523,8 +506,7 @@ Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) const {
// FIXME: Remove once Godot 3.1 has been released // FIXME: Remove once Godot 3.1 has been released
float Color::gray() const { float Color::gray() const {
ERR_EXPLAIN("Color.gray() is deprecated and will be removed in a future version. Use Color.get_v() for a better grayscale approximation."); WARN_DEPRECATED_MSG("Color.gray() is deprecated and will be removed in a future version. Use Color.get_v() for a better grayscale approximation.");
WARN_DEPRECATED;
return (r + g + b) / 3.0; return (r + g + b) / 3.0;
} }

View File

@ -197,10 +197,7 @@ void Engine::add_singleton(const Singleton &p_singleton) {
Object *Engine::get_singleton_object(const String &p_name) const { Object *Engine::get_singleton_object(const String &p_name) const {
const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name); const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
if (!E) { ERR_FAIL_COND_V_MSG(!E, NULL, "Failed to retrieve non-existent singleton '" + p_name + "'.");
ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'");
ERR_FAIL_V(NULL);
}
return E->get(); return E->get();
}; };

View File

@ -151,11 +151,7 @@ private:
return; return;
Element **new_hash_table = memnew_arr(Element *, ((uint64_t)1 << new_hash_table_power)); Element **new_hash_table = memnew_arr(Element *, ((uint64_t)1 << new_hash_table_power));
if (!new_hash_table) { ERR_FAIL_COND_MSG(!new_hash_table, "Out of memory.");
ERR_PRINT("Out of Memory");
return;
}
for (int i = 0; i < (1 << new_hash_table_power); i++) { for (int i = 0; i < (1 << new_hash_table_power); i++) {
@ -208,10 +204,7 @@ private:
/* if element doesn't exist, create it */ /* if element doesn't exist, create it */
Element *e = memnew(Element); Element *e = memnew(Element);
if (!e) { ERR_FAIL_COND_V_MSG(!e, NULL, "Out of memory.");
ERR_EXPLAIN("Out of memory");
ERR_FAIL_V(NULL);
}
uint32_t hash = Hasher::hash(p_key); uint32_t hash = Hasher::hash(p_key);
uint32_t index = hash & ((1 << hash_table_power) - 1); uint32_t index = hash & ((1 << hash_table_power) - 1);
e->next = hash_table[index]; e->next = hash_table[index];
@ -498,10 +491,7 @@ public:
} else { /* get the next key */ } else { /* get the next key */
const Element *e = get_element(*p_key); const Element *e = get_element(*p_key);
if (!e) { ERR_FAIL_COND_V_MSG(!e, NULL, "Invalid key supplied.");
ERR_EXPLAIN("Invalid key supplied")
ERR_FAIL_V(NULL);
}
if (e->next) { if (e->next) {
/* if there is a "next" in the list, return that */ /* if there is a "next" in the list, return that */
return &e->next->pair.key; return &e->next->pair.key;

View File

@ -423,8 +423,7 @@ void Image::convert(Format p_new_format) {
if (format > FORMAT_RGBE9995 || p_new_format > FORMAT_RGBE9995) { if (format > FORMAT_RGBE9995 || p_new_format > FORMAT_RGBE9995) {
ERR_EXPLAIN("Cannot convert to <-> from compressed formats. Use compress() and decompress() instead."); ERR_FAIL_MSG("Cannot convert to <-> from compressed formats. Use compress() and decompress() instead.");
ERR_FAIL();
} else if (format > FORMAT_RGBA8 || p_new_format > FORMAT_RGBA8) { } else if (format > FORMAT_RGBA8 || p_new_format > FORMAT_RGBA8) {
@ -864,10 +863,7 @@ bool Image::is_size_po2() const {
void Image::resize_to_po2(bool p_square) { void Image::resize_to_po2(bool p_square) {
if (!_can_modify(format)) { ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot resize in indexed, compressed or custom image formats.");
ERR_EXPLAIN("Cannot resize in indexed, compressed or custom image formats.");
ERR_FAIL();
}
int w = next_power_of_2(width); int w = next_power_of_2(width);
int h = next_power_of_2(height); int h = next_power_of_2(height);
@ -883,15 +879,9 @@ void Image::resize_to_po2(bool p_square) {
void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
if (data.size() == 0) { ERR_FAIL_COND_MSG(data.size() == 0, "Cannot resize image before creating it, use create() or create_from_data() first.");
ERR_EXPLAIN("Cannot resize image before creating it, use create() or create_from_data() first.");
ERR_FAIL();
}
if (!_can_modify(format)) { ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot resize in indexed, compressed or custom image formats.");
ERR_EXPLAIN("Cannot resize in indexed, compressed or custom image formats.");
ERR_FAIL();
}
bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */; bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */;
@ -1104,10 +1094,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) { void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
if (!_can_modify(format)) { ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot crop in indexed, compressed or custom image formats.");
ERR_EXPLAIN("Cannot crop in indexed, compressed or custom image formats.");
ERR_FAIL();
}
ERR_FAIL_COND(p_x < 0); ERR_FAIL_COND(p_x < 0);
ERR_FAIL_COND(p_y < 0); ERR_FAIL_COND(p_y < 0);
ERR_FAIL_COND(p_width <= 0); ERR_FAIL_COND(p_width <= 0);
@ -1161,10 +1149,7 @@ void Image::crop(int p_width, int p_height) {
void Image::flip_y() { void Image::flip_y() {
if (!_can_modify(format)) { ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot flip_y in indexed, compressed or custom image formats.");
ERR_EXPLAIN("Cannot flip_y in indexed, compressed or custom image formats.");
ERR_FAIL();
}
bool used_mipmaps = has_mipmaps(); bool used_mipmaps = has_mipmaps();
if (used_mipmaps) { if (used_mipmaps) {
@ -1197,10 +1182,7 @@ void Image::flip_y() {
void Image::flip_x() { void Image::flip_x() {
if (!_can_modify(format)) { ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot flip_x in indexed, compressed or custom image formats.");
ERR_EXPLAIN("Cannot flip_x in indexed, compressed or custom image formats.");
ERR_FAIL();
}
bool used_mipmaps = has_mipmaps(); bool used_mipmaps = has_mipmaps();
if (used_mipmaps) { if (used_mipmaps) {
@ -1459,15 +1441,9 @@ void Image::normalize() {
Error Image::generate_mipmaps(bool p_renormalize) { Error Image::generate_mipmaps(bool p_renormalize) {
if (!_can_modify(format)) { ERR_FAIL_COND_V_MSG(!_can_modify(format), ERR_UNAVAILABLE, "Cannot generate mipmaps in indexed, compressed or custom image formats.");
ERR_EXPLAIN("Cannot generate mipmaps in indexed, compressed or custom image formats.");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
if (width == 0 || height == 0) { ERR_FAIL_COND_V_MSG(width == 0 || height == 0, ERR_UNCONFIGURED, "Cannot generate mipmaps with width or height equal to 0.");
ERR_EXPLAIN("Cannot generate mipmaps with width or height equal to 0.");
ERR_FAIL_V(ERR_UNCONFIGURED);
}
int mmcount; int mmcount;
@ -1618,10 +1594,7 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
int mm; int mm;
int size = _get_dst_image_size(p_width, p_height, p_format, mm, p_use_mipmaps ? -1 : 0); int size = _get_dst_image_size(p_width, p_height, p_format, mm, p_use_mipmaps ? -1 : 0);
if (size != p_data.size()) { ERR_FAIL_COND_MSG(p_data.size() != size, "Expected data size of " + itos(size) + " bytes in Image::create(), got instead " + itos(p_data.size()) + " bytes.");
ERR_EXPLAIN("Expected data size of " + itos(size) + " bytes in Image::create(), got instead " + itos(p_data.size()) + " bytes.");
ERR_FAIL_COND(p_data.size() != size);
}
height = p_height; height = p_height;
width = p_width; width = p_width;
@ -2411,10 +2384,7 @@ Color Image::get_pixel(int p_x, int p_y) const {
uint8_t *ptr = write_lock.ptr(); uint8_t *ptr = write_lock.ptr();
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (!ptr) { ERR_FAIL_COND_V_MSG(!ptr, Color(), "Image must be locked with 'lock()' before using get_pixel().");
ERR_EXPLAIN("Image must be locked with 'lock()' before using get_pixel()");
ERR_FAIL_V(Color());
}
ERR_FAIL_INDEX_V(p_x, width, Color()); ERR_FAIL_INDEX_V(p_x, width, Color());
ERR_FAIL_INDEX_V(p_y, height, Color()); ERR_FAIL_INDEX_V(p_y, height, Color());
@ -2530,8 +2500,7 @@ Color Image::get_pixel(int p_x, int p_y) const {
return Color::from_rgbe9995(((uint32_t *)ptr)[ofs]); return Color::from_rgbe9995(((uint32_t *)ptr)[ofs]);
} }
default: { default: {
ERR_EXPLAIN("Can't get_pixel() on compressed image, sorry."); ERR_FAIL_V_MSG(Color(), "Can't get_pixel() on compressed image, sorry.");
ERR_FAIL_V(Color());
} }
} }
} }
@ -2544,10 +2513,7 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
uint8_t *ptr = write_lock.ptr(); uint8_t *ptr = write_lock.ptr();
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (!ptr) { ERR_FAIL_COND_MSG(!ptr, "Image must be locked with 'lock()' before using set_pixel().");
ERR_EXPLAIN("Image must be locked with 'lock()' before using set_pixel()");
ERR_FAIL();
}
ERR_FAIL_INDEX(p_x, width); ERR_FAIL_INDEX(p_x, width);
ERR_FAIL_INDEX(p_y, height); ERR_FAIL_INDEX(p_y, height);
@ -2659,8 +2625,7 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
} break; } break;
default: { default: {
ERR_EXPLAIN("Can't set_pixel() on compressed image, sorry."); ERR_FAIL_MSG("Can't set_pixel() on compressed image, sorry.");
ERR_FAIL();
} }
} }
} }

View File

@ -192,10 +192,7 @@ bool InputMap::event_is_action(const Ref<InputEvent> &p_event, const StringName
bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed, float *p_strength) const { bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed, float *p_strength) const {
Map<StringName, Action>::Element *E = input_map.find(p_action); Map<StringName, Action>::Element *E = input_map.find(p_action);
if (!E) { ERR_FAIL_COND_V_MSG(!E, false, "Request for nonexistent InputMap action: " + String(p_action) + ".");
ERR_EXPLAIN("Request for nonexistent InputMap action: " + String(p_action));
ERR_FAIL_V(false);
}
Ref<InputEventAction> input_event_action = p_event; Ref<InputEventAction> input_event_action = p_event;
if (input_event_action.is_valid()) { if (input_event_action.is_valid()) {

View File

@ -86,10 +86,7 @@ void ConfigFile::set_value(const String &p_section, const String &p_key, const V
Variant ConfigFile::get_value(const String &p_section, const String &p_key, Variant p_default) const { Variant ConfigFile::get_value(const String &p_section, const String &p_key, Variant p_default) const {
if (!values.has(p_section) || !values[p_section].has(p_key)) { if (!values.has(p_section) || !values[p_section].has(p_key)) {
if (p_default.get_type() == Variant::NIL) { ERR_FAIL_COND_V_MSG(p_default.get_type() == Variant::NIL, p_default, "Couldn't find the given section/key and no default was given.");
ERR_EXPLAIN("Couldn't find the given section/key and no default was given");
ERR_FAIL_V(p_default);
}
return p_default; return p_default;
} }
return values[p_section][p_key]; return values[p_section][p_key];
@ -271,7 +268,7 @@ Error ConfigFile::_internal_load(const String &p_path, FileAccess *f) {
memdelete(f); memdelete(f);
return OK; return OK;
} else if (err != OK) { } else if (err != OK) {
ERR_PRINTS("ConfgFile::load - " + p_path + ":" + itos(lines) + " error: " + error_text); ERR_PRINTS("ConfgFile::load - " + p_path + ":" + itos(lines) + " error: " + error_text + ".");
memdelete(f); memdelete(f);
return err; return err;
} }

View File

@ -87,10 +87,8 @@ bool FileAccessBuffered::eof_reached() const {
} }
uint8_t FileAccessBuffered::get_8() const { uint8_t FileAccessBuffered::get_8() const {
if (!file.open) {
ERR_EXPLAIN("Can't get data, when file is not opened."); ERR_FAIL_COND_V_MSG(!file.open, 0, "Can't get data, when file is not opened.");
ERR_FAIL_V(0);
}
uint8_t byte = 0; uint8_t byte = 0;
if (cache_data_left() >= 1) { if (cache_data_left() >= 1) {
@ -104,10 +102,8 @@ uint8_t FileAccessBuffered::get_8() const {
} }
int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const { int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
if (!file.open) {
ERR_EXPLAIN("Can't get buffer, when file is not opened."); ERR_FAIL_COND_V_MSG(!file.open, -1, "Can't get buffer, when file is not opened.");
ERR_FAIL_V(-1);
}
if (p_length > cache_size) { if (p_length > cache_size) {

View File

@ -94,8 +94,7 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
unsigned char hash[16]; unsigned char hash[16];
ERR_FAIL_COND_V(CryptoCore::md5(data.ptr(), data.size(), hash) != OK, ERR_BUG); ERR_FAIL_COND_V(CryptoCore::md5(data.ptr(), data.size(), hash) != OK, ERR_BUG);
ERR_EXPLAIN("The MD5 sum of the decrypted file does not match the expected value. It could be that the file is corrupt, or that the provided decryption key is invalid."); ERR_FAIL_COND_V_MSG(String::md5(hash) != String::md5(md5d), ERR_FILE_CORRUPT, "The MD5 sum of the decrypted file does not match the expected value. It could be that the file is corrupt, or that the provided decryption key is invalid.");
ERR_FAIL_COND_V(String::md5(hash) != String::md5(md5d), ERR_FILE_CORRUPT);
file = p_base; file = p_base;
} }
@ -298,7 +297,7 @@ uint32_t FileAccessEncrypted::_get_unix_permissions(const String &p_file) {
} }
Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t p_permissions) { Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t p_permissions) {
ERR_PRINT("Setting UNIX permissions on encrypted files is not implemented yet"); ERR_PRINT("Setting UNIX permissions on encrypted files is not implemented yet.");
return ERR_UNAVAILABLE; return ERR_UNAVAILABLE;
} }

View File

@ -171,10 +171,8 @@ bool PackedSourcePCK::try_open_pack(const String &p_path) {
uint32_t ver_minor = f->get_32(); uint32_t ver_minor = f->get_32();
f->get_32(); // ver_rev f->get_32(); // ver_rev
ERR_EXPLAIN("Pack version unsupported: " + itos(version)); ERR_FAIL_COND_V_MSG(version != PACK_VERSION, false, "Pack version unsupported: " + itos(version) + ".");
ERR_FAIL_COND_V(version != PACK_VERSION, false); ERR_FAIL_COND_V_MSG(ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), false, "Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor) + ".");
ERR_EXPLAIN("Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor));
ERR_FAIL_COND_V(ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), false);
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
//reserved //reserved
@ -322,10 +320,9 @@ bool FileAccessPack::file_exists(const String &p_name) {
FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) : FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) :
pf(p_file), pf(p_file),
f(FileAccess::open(pf.pack, FileAccess::READ)) { f(FileAccess::open(pf.pack, FileAccess::READ)) {
if (!f) {
ERR_EXPLAIN("Can't open pack-referenced file: " + String(pf.pack)); ERR_FAIL_COND_MSG(!f, "Can't open pack-referenced file: " + String(pf.pack) + ".");
ERR_FAIL_COND(!f);
}
f->seek(pf.offset); f->seek(pf.offset);
pos = 0; pos = 0;
eof = false; eof = false;

View File

@ -81,8 +81,7 @@ static void _parse_hex(const String &p_string, int p_start, uint8_t *p_dst) {
} else if (c == ':') { } else if (c == ':') {
break; break;
} else { } else {
ERR_EXPLAIN("Invalid character in ipv6 address: " + p_string); ERR_FAIL_MSG("Invalid character in IPv6 address: " + p_string + ".");
ERR_FAIL();
}; };
ret = ret << 4; ret = ret << 4;
ret += n; ret += n;
@ -126,9 +125,7 @@ void IP_Address::_parse_ipv6(const String &p_string) {
++parts_count; ++parts_count;
}; };
} else { } else {
ERR_FAIL_MSG("Invalid character in IPv6 address: " + p_string + ".");
ERR_EXPLAIN("Invalid character in IPv6 address: " + p_string);
ERR_FAIL();
}; };
}; };
@ -166,10 +163,7 @@ void IP_Address::_parse_ipv4(const String &p_string, int p_start, uint8_t *p_ret
}; };
int slices = ip.get_slice_count("."); int slices = ip.get_slice_count(".");
if (slices != 4) { ERR_FAIL_COND_MSG(slices != 4, "Invalid IP address string: " + ip + ".");
ERR_EXPLAIN("Invalid IP Address String: " + ip);
ERR_FAIL();
}
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
p_ret[i] = ip.get_slicec('.', i).to_int(); p_ret[i] = ip.get_slicec('.', i).to_int();
} }
@ -229,7 +223,7 @@ IP_Address::IP_Address(const String &p_string) {
valid = true; valid = true;
} else { } else {
ERR_PRINT("Invalid IP address"); ERR_PRINT("Invalid IP address.");
} }
} }

View File

@ -377,11 +377,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} }
} break; } break;
/*case Variant::RESOURCE: {
ERR_EXPLAIN("Can't marshallize resources");
ERR_FAIL_V(ERR_INVALID_DATA); //no, i'm sorry, no go
} break;*/
case Variant::_RID: { case Variant::_RID: {
r_variant = RID(); r_variant = RID();
@ -1066,11 +1061,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 * 4; r_len += 4 * 4;
} break; } break;
/*case Variant::RESOURCE: {
ERR_EXPLAIN("Can't marshallize resources");
ERR_FAIL_V(ERR_INVALID_DATA); //no, i'm sorry, no go
} break;*/
case Variant::_RID: { case Variant::_RID: {
} break; } break;

View File

@ -146,8 +146,7 @@ void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_pee
network_peer = p_peer; network_peer = p_peer;
ERR_EXPLAIN("Supplied NetworkedNetworkPeer must be connecting or connected."); ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED, "Supplied NetworkedNetworkPeer must be connecting or connected.");
ERR_FAIL_COND(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED);
if (network_peer.is_valid()) { if (network_peer.is_valid()) {
network_peer->connect("peer_connected", this, "_add_peer"); network_peer->connect("peer_connected", this, "_add_peer");
@ -164,10 +163,8 @@ Ref<NetworkedMultiplayerPeer> MultiplayerAPI::get_network_peer() const {
void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len) { void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_EXPLAIN("Multiplayer root node was not initialized. If you are using custom multiplayer, remember to set the root node via MultiplayerAPI.set_root_node before using it"); ERR_FAIL_COND_MSG(root_node == NULL, "Multiplayer root node was not initialized. If you are using custom multiplayer, remember to set the root node via MultiplayerAPI.set_root_node before using it.");
ERR_FAIL_COND(root_node == NULL); ERR_FAIL_COND_MSG(p_packet_len < 1, "Invalid packet received. Size too small.");
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 1);
uint8_t packet_type = p_packet[0]; uint8_t packet_type = p_packet[0];
@ -186,13 +183,11 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_
case NETWORK_COMMAND_REMOTE_CALL: case NETWORK_COMMAND_REMOTE_CALL:
case NETWORK_COMMAND_REMOTE_SET: { case NETWORK_COMMAND_REMOTE_SET: {
ERR_EXPLAIN("Invalid packet received. Size too small."); ERR_FAIL_COND_MSG(p_packet_len < 6, "Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 6);
Node *node = _process_get_node(p_from, p_packet, p_packet_len); Node *node = _process_get_node(p_from, p_packet, p_packet_len);
ERR_EXPLAIN("Invalid packet received. Requested node was not found."); ERR_FAIL_COND_MSG(node == NULL, "Invalid packet received. Requested node was not found.");
ERR_FAIL_COND(node == NULL);
// Detect cstring end. // Detect cstring end.
int len_end = 5; int len_end = 5;
@ -202,8 +197,7 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_
} }
} }
ERR_EXPLAIN("Invalid packet received. Size too small."); ERR_FAIL_COND_MSG(len_end >= p_packet_len, "Invalid packet received. Size too small.");
ERR_FAIL_COND(len_end >= p_packet_len);
StringName name = String::utf8((const char *)&p_packet[5]); StringName name = String::utf8((const char *)&p_packet[5]);
@ -235,8 +229,7 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, int
int ofs = target & 0x7FFFFFFF; int ofs = target & 0x7FFFFFFF;
ERR_EXPLAIN("Invalid packet received. Size smaller than declared."); ERR_FAIL_COND_V_MSG(ofs >= p_packet_len, NULL, "Invalid packet received. Size smaller than declared.");
ERR_FAIL_COND_V(ofs >= p_packet_len, NULL);
String paths; String paths;
paths.parse_utf8((const char *)&p_packet[ofs], p_packet_len - ofs); paths.parse_utf8((const char *)&p_packet[ofs], p_packet_len - ofs);
@ -246,33 +239,30 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, int
node = root_node->get_node(np); node = root_node->get_node(np);
if (!node) if (!node)
ERR_PRINTS("Failed to get path from RPC: " + String(np)); ERR_PRINTS("Failed to get path from RPC: " + String(np) + ".");
} else { } else {
// Use cached path. // Use cached path.
int id = target; int id = target;
Map<int, PathGetCache>::Element *E = path_get_cache.find(p_from); Map<int, PathGetCache>::Element *E = path_get_cache.find(p_from);
ERR_EXPLAIN("Invalid packet received. Requests invalid peer cache."); ERR_FAIL_COND_V_MSG(!E, NULL, "Invalid packet received. Requests invalid peer cache.");
ERR_FAIL_COND_V(!E, NULL);
Map<int, PathGetCache::NodeInfo>::Element *F = E->get().nodes.find(id); Map<int, PathGetCache::NodeInfo>::Element *F = E->get().nodes.find(id);
ERR_EXPLAIN("Invalid packet received. Unabled to find requested cached node."); ERR_FAIL_COND_V_MSG(!F, NULL, "Invalid packet received. Unabled to find requested cached node.");
ERR_FAIL_COND_V(!F, NULL);
PathGetCache::NodeInfo *ni = &F->get(); PathGetCache::NodeInfo *ni = &F->get();
// Do proper caching later. // Do proper caching later.
node = root_node->get_node(ni->path); node = root_node->get_node(ni->path);
if (!node) if (!node)
ERR_PRINTS("Failed to get cached path from RPC: " + String(ni->path)); ERR_PRINTS("Failed to get cached path from RPC: " + String(ni->path) + ".");
} }
return node; return node;
} }
void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset) { void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset) {
ERR_EXPLAIN("Invalid packet received. Size too small."); ERR_FAIL_COND_MSG(p_offset >= p_packet_len, "Invalid packet received. Size too small.");
ERR_FAIL_COND(p_offset >= p_packet_len);
// Check that remote can call the RPC on this node. // Check that remote can call the RPC on this node.
RPCMode rpc_mode = RPC_MODE_DISABLED; RPCMode rpc_mode = RPC_MODE_DISABLED;
@ -284,8 +274,7 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_
} }
bool can_call = _can_call_mode(p_node, rpc_mode, p_from); bool can_call = _can_call_mode(p_node, rpc_mode, p_from);
ERR_EXPLAIN("RPC '" + String(p_name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rpc_mode) + ", master is " + itos(p_node->get_network_master()) + "."); ERR_FAIL_COND_MSG(!can_call, "RPC '" + String(p_name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rpc_mode) + ", master is " + itos(p_node->get_network_master()) + ".");
ERR_FAIL_COND(!can_call);
int argc = p_packet[p_offset]; int argc = p_packet[p_offset];
Vector<Variant> args; Vector<Variant> args;
@ -297,13 +286,11 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_
for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) {
ERR_EXPLAIN("Invalid packet received. Size too small."); ERR_FAIL_COND_MSG(p_offset >= p_packet_len, "Invalid packet received. Size too small.");
ERR_FAIL_COND(p_offset >= p_packet_len);
int vlen; int vlen;
Error err = decode_variant(args.write[i], &p_packet[p_offset], p_packet_len - p_offset, &vlen, allow_object_decoding || network_peer->is_object_decoding_allowed()); Error err = decode_variant(args.write[i], &p_packet[p_offset], p_packet_len - p_offset, &vlen, allow_object_decoding || network_peer->is_object_decoding_allowed());
ERR_EXPLAIN("Invalid packet received. Unable to decode RPC argument."); ERR_FAIL_COND_MSG(err != OK, "Invalid packet received. Unable to decode RPC argument.");
ERR_FAIL_COND(err != OK);
argp.write[i] = &args[i]; argp.write[i] = &args[i];
p_offset += vlen; p_offset += vlen;
@ -321,8 +308,7 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_
void MultiplayerAPI::_process_rset(Node *p_node, const StringName &p_name, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset) { void MultiplayerAPI::_process_rset(Node *p_node, const StringName &p_name, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset) {
ERR_EXPLAIN("Invalid packet received. Size too small."); ERR_FAIL_COND_MSG(p_offset >= p_packet_len, "Invalid packet received. Size too small.");
ERR_FAIL_COND(p_offset >= p_packet_len);
// Check that remote can call the RSET on this node. // Check that remote can call the RSET on this node.
RPCMode rset_mode = RPC_MODE_DISABLED; RPCMode rset_mode = RPC_MODE_DISABLED;
@ -334,28 +320,25 @@ void MultiplayerAPI::_process_rset(Node *p_node, const StringName &p_name, int p
} }
bool can_call = _can_call_mode(p_node, rset_mode, p_from); bool can_call = _can_call_mode(p_node, rset_mode, p_from);
ERR_EXPLAIN("RSET '" + String(p_name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rset_mode) + ", master is " + itos(p_node->get_network_master()) + "."); ERR_FAIL_COND_MSG(!can_call, "RSET '" + String(p_name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rset_mode) + ", master is " + itos(p_node->get_network_master()) + ".");
ERR_FAIL_COND(!can_call);
Variant value; Variant value;
Error err = decode_variant(value, &p_packet[p_offset], p_packet_len - p_offset, NULL, allow_object_decoding || network_peer->is_object_decoding_allowed()); Error err = decode_variant(value, &p_packet[p_offset], p_packet_len - p_offset, NULL, allow_object_decoding || network_peer->is_object_decoding_allowed());
ERR_EXPLAIN("Invalid packet received. Unable to decode RSET value."); ERR_FAIL_COND_MSG(err != OK, "Invalid packet received. Unable to decode RSET value.");
ERR_FAIL_COND(err != OK);
bool valid; bool valid;
p_node->set(p_name, value, &valid); p_node->set(p_name, value, &valid);
if (!valid) { if (!valid) {
String error = "Error setting remote property '" + String(p_name) + "', not found in object of type " + p_node->get_class(); String error = "Error setting remote property '" + String(p_name) + "', not found in object of type " + p_node->get_class() + ".";
ERR_PRINTS(error); ERR_PRINTS(error);
} }
} }
void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet, int p_packet_len) { void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_EXPLAIN("Invalid packet received. Size too small."); ERR_FAIL_COND_MSG(p_packet_len < 5, "Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 5);
int id = decode_uint32(&p_packet[1]); int id = decode_uint32(&p_packet[1]);
String paths; String paths;
@ -390,8 +373,7 @@ void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet,
void MultiplayerAPI::_process_confirm_path(int p_from, const uint8_t *p_packet, int p_packet_len) { void MultiplayerAPI::_process_confirm_path(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_EXPLAIN("Invalid packet received. Size too small."); ERR_FAIL_COND_MSG(p_packet_len < 2, "Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 2);
String paths; String paths;
paths.parse_utf8((const char *)&p_packet[1], p_packet_len - 1); paths.parse_utf8((const char *)&p_packet[1], p_packet_len - 1);
@ -399,12 +381,10 @@ void MultiplayerAPI::_process_confirm_path(int p_from, const uint8_t *p_packet,
NodePath path = paths; NodePath path = paths;
PathSentCache *psc = path_send_cache.getptr(path); PathSentCache *psc = path_send_cache.getptr(path);
ERR_EXPLAIN("Invalid packet received. Tries to confirm a path which was not found in cache."); ERR_FAIL_COND_MSG(!psc, "Invalid packet received. Tries to confirm a path which was not found in cache.");
ERR_FAIL_COND(!psc);
Map<int, bool>::Element *E = psc->confirmed_peers.find(p_from); Map<int, bool>::Element *E = psc->confirmed_peers.find(p_from);
ERR_EXPLAIN("Invalid packet received. Source peer was not found in cache for the given path."); ERR_FAIL_COND_MSG(!E, "Invalid packet received. Source peer was not found in cache for the given path.");
ERR_FAIL_COND(!E);
E->get() = true; E->get() = true;
} }
@ -460,39 +440,22 @@ bool MultiplayerAPI::_send_confirm_path(NodePath p_path, PathSentCache *psc, int
void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p_set, const StringName &p_name, const Variant **p_arg, int p_argcount) { void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p_set, const StringName &p_name, const Variant **p_arg, int p_argcount) {
if (network_peer.is_null()) { ERR_FAIL_COND_MSG(network_peer.is_null(), "Attempt to remote call/set when networking is not active in SceneTree.");
ERR_EXPLAIN("Attempt to remote call/set when networking is not active in SceneTree.");
ERR_FAIL();
}
if (network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_CONNECTING) { ERR_FAIL_COND_MSG(network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_CONNECTING, "Attempt to remote call/set when networking is not connected yet in SceneTree.");
ERR_EXPLAIN("Attempt to remote call/set when networking is not connected yet in SceneTree.");
ERR_FAIL();
}
if (network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED) { ERR_FAIL_COND_MSG(network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED, "Attempt to remote call/set when networking is disconnected.");
ERR_EXPLAIN("Attempt to remote call/set when networking is disconnected.");
ERR_FAIL();
}
if (p_argcount > 255) { ERR_FAIL_COND_MSG(p_argcount > 255, "Too many arguments >255.");
ERR_EXPLAIN("Too many arguments >255.");
ERR_FAIL();
}
if (p_to != 0 && !connected_peers.has(ABS(p_to))) { if (p_to != 0 && !connected_peers.has(ABS(p_to))) {
if (p_to == network_peer->get_unique_id()) { ERR_FAIL_COND_MSG(p_to == network_peer->get_unique_id(), "Attempt to remote call/set yourself! unique ID: " + itos(network_peer->get_unique_id()) + ".");
ERR_EXPLAIN("Attempt to remote call/set yourself! unique ID: " + itos(network_peer->get_unique_id()));
} else {
ERR_EXPLAIN("Attempt to remote call unexisting ID: " + itos(p_to));
}
ERR_FAIL(); ERR_FAIL_MSG("Attempt to remote call unexisting ID: " + itos(p_to) + ".");
} }
NodePath from_path = (root_node->get_path()).rel_path_to(p_from->get_path()); NodePath from_path = (root_node->get_path()).rel_path_to(p_from->get_path());
ERR_EXPLAIN("Unable to send RPC. Relative path is empty. THIS IS LIKELY A BUG IN THE ENGINE!"); ERR_FAIL_COND_MSG(from_path.is_empty(), "Unable to send RPC. Relative path is empty. THIS IS LIKELY A BUG IN THE ENGINE!");
ERR_FAIL_COND(from_path.is_empty());
// See if the path is cached. // See if the path is cached.
PathSentCache *psc = path_send_cache.getptr(from_path); PathSentCache *psc = path_send_cache.getptr(from_path);
@ -530,8 +493,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
if (p_set) { if (p_set) {
// Set argument. // Set argument.
Error err = encode_variant(*p_arg[0], NULL, len, allow_object_decoding || network_peer->is_object_decoding_allowed()); Error err = encode_variant(*p_arg[0], NULL, len, allow_object_decoding || network_peer->is_object_decoding_allowed());
ERR_EXPLAIN("Unable to encode RSET value. THIS IS LIKELY A BUG IN THE ENGINE!"); ERR_FAIL_COND_MSG(err != OK, "Unable to encode RSET value. THIS IS LIKELY A BUG IN THE ENGINE!");
ERR_FAIL_COND(err != OK);
MAKE_ROOM(ofs + len); MAKE_ROOM(ofs + len);
encode_variant(*p_arg[0], &(packet_cache.write[ofs]), len, allow_object_decoding || network_peer->is_object_decoding_allowed()); encode_variant(*p_arg[0], &(packet_cache.write[ofs]), len, allow_object_decoding || network_peer->is_object_decoding_allowed());
ofs += len; ofs += len;
@ -543,8 +505,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
ofs += 1; ofs += 1;
for (int i = 0; i < p_argcount; i++) { for (int i = 0; i < p_argcount; i++) {
Error err = encode_variant(*p_arg[i], NULL, len, allow_object_decoding || network_peer->is_object_decoding_allowed()); Error err = encode_variant(*p_arg[i], NULL, len, allow_object_decoding || network_peer->is_object_decoding_allowed());
ERR_EXPLAIN("Unable to encode RPC argument. THIS IS LIKELY A BUG IN THE ENGINE!"); ERR_FAIL_COND_MSG(err != OK, "Unable to encode RPC argument. THIS IS LIKELY A BUG IN THE ENGINE!");
ERR_FAIL_COND(err != OK);
MAKE_ROOM(ofs + len); MAKE_ROOM(ofs + len);
encode_variant(*p_arg[i], &(packet_cache.write[ofs]), len, allow_object_decoding || network_peer->is_object_decoding_allowed()); encode_variant(*p_arg[i], &(packet_cache.write[ofs]), len, allow_object_decoding || network_peer->is_object_decoding_allowed());
ofs += len; ofs += len;
@ -626,12 +587,9 @@ void MultiplayerAPI::_server_disconnected() {
void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) { void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) {
ERR_EXPLAIN("Trying to call an RPC while no network peer is active."); ERR_FAIL_COND_MSG(!network_peer.is_valid(), "Trying to call an RPC while no network peer is active.");
ERR_FAIL_COND(!network_peer.is_valid()); ERR_FAIL_COND_MSG(!p_node->is_inside_tree(), "Trying to call an RPC on a node which is not inside SceneTree.");
ERR_EXPLAIN("Trying to call an RPC on a node which is not inside SceneTree."); ERR_FAIL_COND_MSG(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, "Trying to call an RPC via a network peer which is not connected.");
ERR_FAIL_COND(!p_node->is_inside_tree());
ERR_EXPLAIN("Trying to call an RPC via a network peer which is not connected.");
ERR_FAIL_COND(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED);
int node_id = network_peer->get_unique_id(); int node_id = network_peer->get_unique_id();
bool skip_rpc = node_id == p_peer_id; bool skip_rpc = node_id == p_peer_id;
@ -668,7 +626,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
rpc_sender_id = temp_id; rpc_sender_id = temp_id;
if (ce.error != Variant::CallError::CALL_OK) { if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce); String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce);
error = "rpc() aborted in local call: - " + error; error = "rpc() aborted in local call: - " + error + ".";
ERR_PRINTS(error); ERR_PRINTS(error);
return; return;
} }
@ -683,24 +641,20 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
rpc_sender_id = temp_id; rpc_sender_id = temp_id;
if (ce.error != Variant::CallError::CALL_OK) { if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce); String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce);
error = "rpc() aborted in script local call: - " + error; error = "rpc() aborted in script local call: - " + error + ".";
ERR_PRINTS(error); ERR_PRINTS(error);
return; return;
} }
} }
ERR_EXPLAIN("RPC '" + p_method + "' on yourself is not allowed by selected mode"); ERR_FAIL_COND_MSG(skip_rpc && !(call_local_native || call_local_script), "RPC '" + p_method + "' on yourself is not allowed by selected mode.");
ERR_FAIL_COND(skip_rpc && !(call_local_native || call_local_script));
} }
void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_property, const Variant &p_value) { void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_property, const Variant &p_value) {
ERR_EXPLAIN("Trying to RSET while no network peer is active."); ERR_FAIL_COND_MSG(!network_peer.is_valid(), "Trying to RSET while no network peer is active.");
ERR_FAIL_COND(!network_peer.is_valid()); ERR_FAIL_COND_MSG(!p_node->is_inside_tree(), "Trying to RSET on a node which is not inside SceneTree.");
ERR_EXPLAIN("Trying to RSET on a node which is not inside SceneTree."); ERR_FAIL_COND_MSG(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, "Trying to send an RSET via a network peer which is not connected.");
ERR_FAIL_COND(!p_node->is_inside_tree());
ERR_EXPLAIN("Trying to send an RSET via a network peer which is not connected.");
ERR_FAIL_COND(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED);
int node_id = network_peer->get_unique_id(); int node_id = network_peer->get_unique_id();
bool is_master = p_node->is_network_master(); bool is_master = p_node->is_network_master();
@ -724,7 +678,7 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const
rpc_sender_id = temp_id; rpc_sender_id = temp_id;
if (!valid) { if (!valid) {
String error = "rset() aborted in local set, property not found: - " + String(p_property); String error = "rset() aborted in local set, property not found: - " + String(p_property) + ".";
ERR_PRINTS(error); ERR_PRINTS(error);
return; return;
} }
@ -742,7 +696,7 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const
rpc_sender_id = temp_id; rpc_sender_id = temp_id;
if (!valid) { if (!valid) {
String error = "rset() aborted in local script set, property not found: - " + String(p_property); String error = "rset() aborted in local script set, property not found: - " + String(p_property) + ".";
ERR_PRINTS(error); ERR_PRINTS(error);
return; return;
} }
@ -751,8 +705,7 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const
} }
if (skip_rset) { if (skip_rset) {
ERR_EXPLAIN("RSET for '" + p_property + "' on yourself is not allowed by selected mode"); ERR_FAIL_COND_MSG(!set_local, "RSET for '" + p_property + "' on yourself is not allowed by selected mode.");
ERR_FAIL_COND(!set_local);
return; return;
} }
@ -763,12 +716,9 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const
Error MultiplayerAPI::send_bytes(PoolVector<uint8_t> p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) { Error MultiplayerAPI::send_bytes(PoolVector<uint8_t> p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) {
ERR_EXPLAIN("Trying to send an empty raw packet."); ERR_FAIL_COND_V_MSG(p_data.size() < 1, ERR_INVALID_DATA, "Trying to send an empty raw packet.");
ERR_FAIL_COND_V(p_data.size() < 1, ERR_INVALID_DATA); ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), ERR_UNCONFIGURED, "Trying to send a raw packet while no network peer is active.");
ERR_EXPLAIN("Trying to send a raw packet while no network peer is active."); ERR_FAIL_COND_V_MSG(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED, "Trying to send a raw packet via a network peer which is not connected.");
ERR_FAIL_COND_V(!network_peer.is_valid(), ERR_UNCONFIGURED);
ERR_EXPLAIN("Trying to send a raw packet via a network peer which is not connected.");
ERR_FAIL_COND_V(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED);
MAKE_ROOM(p_data.size() + 1); MAKE_ROOM(p_data.size() + 1);
PoolVector<uint8_t>::Read r = p_data.read(); PoolVector<uint8_t>::Read r = p_data.read();
@ -783,8 +733,7 @@ Error MultiplayerAPI::send_bytes(PoolVector<uint8_t> p_data, int p_to, Networked
void MultiplayerAPI::_process_raw(int p_from, const uint8_t *p_packet, int p_packet_len) { void MultiplayerAPI::_process_raw(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_EXPLAIN("Invalid packet received. Size too small."); ERR_FAIL_COND_MSG(p_packet_len < 2, "Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 2);
PoolVector<uint8_t> out; PoolVector<uint8_t> out;
int len = p_packet_len - 1; int len = p_packet_len - 1;
@ -798,37 +747,32 @@ void MultiplayerAPI::_process_raw(int p_from, const uint8_t *p_packet, int p_pac
int MultiplayerAPI::get_network_unique_id() const { int MultiplayerAPI::get_network_unique_id() const {
ERR_EXPLAIN("No network peer is assigned. Unable to get unique network ID."); ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), 0, "No network peer is assigned. Unable to get unique network ID.");
ERR_FAIL_COND_V(!network_peer.is_valid(), 0);
return network_peer->get_unique_id(); return network_peer->get_unique_id();
} }
bool MultiplayerAPI::is_network_server() const { bool MultiplayerAPI::is_network_server() const {
// XXX Maybe fail silently? Maybe should actually return true to make development of both local and online multiplayer easier? // XXX Maybe fail silently? Maybe should actually return true to make development of both local and online multiplayer easier?
ERR_EXPLAIN("No network peer is assigned. I can't be a server."); ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), false, "No network peer is assigned. I can't be a server.");
ERR_FAIL_COND_V(!network_peer.is_valid(), false);
return network_peer->is_server(); return network_peer->is_server();
} }
void MultiplayerAPI::set_refuse_new_network_connections(bool p_refuse) { void MultiplayerAPI::set_refuse_new_network_connections(bool p_refuse) {
ERR_EXPLAIN("No network peer is assigned. Unable to set 'refuse_new_connections'."); ERR_FAIL_COND_MSG(!network_peer.is_valid(), "No network peer is assigned. Unable to set 'refuse_new_connections'.");
ERR_FAIL_COND(!network_peer.is_valid());
network_peer->set_refuse_new_connections(p_refuse); network_peer->set_refuse_new_connections(p_refuse);
} }
bool MultiplayerAPI::is_refusing_new_network_connections() const { bool MultiplayerAPI::is_refusing_new_network_connections() const {
ERR_EXPLAIN("No network peer is assigned. Unable to get 'refuse_new_connections'."); ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), false, "No network peer is assigned. Unable to get 'refuse_new_connections'.");
ERR_FAIL_COND_V(!network_peer.is_valid(), false);
return network_peer->is_refusing_new_connections(); return network_peer->is_refusing_new_connections();
} }
Vector<int> MultiplayerAPI::get_network_connected_peers() const { Vector<int> MultiplayerAPI::get_network_connected_peers() const {
ERR_EXPLAIN("No network peer is assigned. Assume no peers are connected."); ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), Vector<int>(), "No network peer is assigned. Assume no peers are connected.");
ERR_FAIL_COND_V(!network_peer.is_valid(), Vector<int>());
Vector<int> ret; Vector<int> ret;
for (Set<int>::Element *E = connected_peers.front(); E; E = E->next()) { for (Set<int>::Element *E = connected_peers.front(); E; E = E->next()) {

View File

@ -280,8 +280,7 @@ Ref<StreamPeer> PacketPeerStream::get_stream_peer() const {
void PacketPeerStream::set_input_buffer_max_size(int p_max_size) { void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
//warning may lose packets //warning may lose packets
ERR_EXPLAIN("Buffer in use, resizing would cause loss of data"); ERR_FAIL_COND_MSG(ring_buffer.data_left(), "Buffer in use, resizing would cause loss of data.");
ERR_FAIL_COND(ring_buffer.data_left());
ring_buffer.resize(nearest_shift(p_max_size + 4)); ring_buffer.resize(nearest_shift(p_max_size + 4));
input_buffer.resize(next_power_of_2(p_max_size + 4)); input_buffer.resize(next_power_of_2(p_max_size + 4));
} }

View File

@ -64,10 +64,7 @@ Error PCKPacker::pck_start(const String &p_file, int p_alignment) {
file = FileAccess::open(p_file, FileAccess::WRITE); file = FileAccess::open(p_file, FileAccess::WRITE);
if (!file) { ERR_FAIL_COND_V_MSG(!file, ERR_CANT_CREATE, "Can't open file to write: " + String(p_file) + ".");
ERR_EXPLAIN("Can't open file to write: " + String(p_file));
ERR_FAIL_V(ERR_CANT_CREATE);
}
alignment = p_alignment; alignment = p_alignment;

View File

@ -490,8 +490,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
#endif #endif
} else { } else {
ERR_EXPLAIN("Vector2 size is NOT 8!"); ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Vector2 size is NOT 8!");
ERR_FAIL_V(ERR_UNAVAILABLE);
} }
w.release(); w.release();
r_v = array; r_v = array;
@ -518,8 +517,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
#endif #endif
} else { } else {
ERR_EXPLAIN("Vector3 size is NOT 12!"); ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Vector3 size is NOT 12!");
ERR_FAIL_V(ERR_UNAVAILABLE);
} }
w.release(); w.release();
r_v = array; r_v = array;
@ -546,8 +544,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
#endif #endif
} else { } else {
ERR_EXPLAIN("Color size is NOT 16!"); ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Color size is NOT 16!");
ERR_FAIL_V(ERR_UNAVAILABLE);
} }
w.release(); w.release();
r_v = array; r_v = array;
@ -571,7 +568,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
const uint32_t current_version = 0; const uint32_t current_version = 0;
if (format_version > current_version) { if (format_version > current_version) {
ERR_PRINT("Format version for encoded binary image is too new"); ERR_PRINT("Format version for encoded binary image is too new.");
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }
@ -655,8 +652,7 @@ Error ResourceInteractiveLoaderBinary::poll() {
} else { } else {
error = ERR_FILE_MISSING_DEPENDENCIES; error = ERR_FILE_MISSING_DEPENDENCIES;
ERR_EXPLAIN("Can't load dependency: " + path); ERR_FAIL_V_MSG(error, "Can't load dependency: " + path + ".");
ERR_FAIL_V(error);
} }
} else { } else {
@ -711,16 +707,15 @@ Error ResourceInteractiveLoaderBinary::poll() {
Object *obj = ClassDB::instance(t); Object *obj = ClassDB::instance(t);
if (!obj) { if (!obj) {
error = ERR_FILE_CORRUPT; error = ERR_FILE_CORRUPT;
ERR_EXPLAIN(local_path + ":Resource of unrecognized type in file: " + t); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, local_path + ":Resource of unrecognized type in file: " + t + ".");
ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
Resource *r = Object::cast_to<Resource>(obj); Resource *r = Object::cast_to<Resource>(obj);
if (!r) { if (!r) {
String obj_class = obj->get_class();
error = ERR_FILE_CORRUPT; error = ERR_FILE_CORRUPT;
ERR_EXPLAIN(local_path + ":Resource type in resource field not a resource, type is: " + obj->get_class());
memdelete(obj); //bye memdelete(obj); //bye
ERR_FAIL_V(ERR_FILE_CORRUPT); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, local_path + ":Resource type in resource field not a resource, type is: " + obj_class + ".");
} }
RES res = RES(r); RES res = RES(r);
@ -850,8 +845,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
//not normal //not normal
error = ERR_FILE_UNRECOGNIZED; error = ERR_FILE_UNRECOGNIZED;
ERR_EXPLAIN("Unrecognized binary resource file: " + local_path); ERR_FAIL_MSG("Unrecognized binary resource file: " + local_path + ".");
ERR_FAIL();
} }
bool big_endian = f->get_32(); bool big_endian = f->get_32();
@ -877,8 +871,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
if (ver_format > FORMAT_VERSION || ver_major > VERSION_MAJOR) { if (ver_format > FORMAT_VERSION || ver_major > VERSION_MAJOR) {
f->close(); f->close();
ERR_EXPLAIN("File Format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a new engine version: " + local_path); ERR_FAIL_MSG("File format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a new engine version: " + local_path + ".");
ERR_FAIL();
} }
type = get_unicode_string(); type = get_unicode_string();
@ -926,8 +919,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
if (f->eof_reached()) { if (f->eof_reached()) {
error = ERR_FILE_CORRUPT; error = ERR_FILE_CORRUPT;
ERR_EXPLAIN("Premature End Of File: " + local_path); ERR_FAIL_MSG("Premature end of file (EOF): " + local_path + ".");
ERR_FAIL();
} }
} }
@ -1084,8 +1076,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
//error=ERR_FILE_UNRECOGNIZED; //error=ERR_FILE_UNRECOGNIZED;
memdelete(f); memdelete(f);
ERR_EXPLAIN("Unrecognized binary resource file: " + local_path); ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unrecognized binary resource file: " + local_path + ".");
ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
} else { } else {
fw = FileAccess::open(p_path + ".depren", FileAccess::WRITE); fw = FileAccess::open(p_path + ".depren", FileAccess::WRITE);
if (!fw) { if (!fw) {
@ -1122,7 +1113,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
memdelete(da); memdelete(da);
//use the old approach //use the old approach
WARN_PRINT(("This file is old, so it can't refactor dependencies, opening and resaving: " + p_path).utf8().get_data()); WARN_PRINTS("This file is old, so it can't refactor dependencies, opening and resaving: " + p_path + ".");
Error err; Error err;
f = FileAccess::open(p_path, FileAccess::READ, &err); f = FileAccess::open(p_path, FileAccess::READ, &err);
@ -1153,8 +1144,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
memdelete(f); memdelete(f);
memdelete(fw); memdelete(fw);
ERR_EXPLAIN("File Format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a new engine version: " + local_path); ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "File format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a new engine version: " + local_path + ".");
ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
} }
// Since we're not actually converting the file contents, leave the version // Since we're not actually converting the file contents, leave the version
@ -1477,7 +1467,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
case Variant::_RID: { case Variant::_RID: {
f->store_32(VARIANT_RID); f->store_32(VARIANT_RID);
WARN_PRINT("Can't save RIDs"); WARN_PRINT("Can't save RIDs.");
RID val = p_property; RID val = p_property;
f->store_32(val.get_id()); f->store_32(val.get_id());
} break; } break;
@ -1497,8 +1487,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
if (!resource_set.has(res)) { if (!resource_set.has(res)) {
f->store_32(OBJECT_EMPTY); f->store_32(OBJECT_EMPTY);
ERR_EXPLAIN("Resource was not pre cached for the resource section, most likely due to circular refedence."); ERR_FAIL_MSG("Resource was not pre cached for the resource section, most likely due to circular reference.");
ERR_FAIL();
} }
f->store_32(OBJECT_INTERNAL_RESOURCE); f->store_32(OBJECT_INTERNAL_RESOURCE);
@ -1629,8 +1618,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break; } break;
default: { default: {
ERR_EXPLAIN("Invalid variant"); ERR_FAIL_MSG("Invalid variant.");
ERR_FAIL();
} }
} }
} }

View File

@ -275,12 +275,9 @@ RES ResourceLoader::_load(const String &p_path, const String &p_original_path, c
return res; return res;
} }
if (found) { ERR_FAIL_COND_V_MSG(found, RES(), "Failed loading resource: " + p_path + ".");
ERR_EXPLAIN("Failed loading resource: " + p_path);
} else { ERR_FAIL_V_MSG(RES(), "No loader found for resource: " + p_path + ".");
ERR_EXPLAIN("No loader found for resource: " + p_path);
}
ERR_FAIL_V(RES());
} }
bool ResourceLoader::_add_to_loading_map(const String &p_path) { bool ResourceLoader::_add_to_loading_map(const String &p_path) {
@ -355,10 +352,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
{ {
bool success = _add_to_loading_map(local_path); bool success = _add_to_loading_map(local_path);
if (!success) { ERR_FAIL_COND_V_MSG(!success, RES(), "Resource: '" + local_path + "' is already being loaded. Cyclic reference?");
ERR_EXPLAIN("Resource: '" + local_path + "' is already being loaded. Cyclic reference?");
ERR_FAIL_V(RES());
}
} }
//lock first if possible //lock first if possible
@ -395,8 +389,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
if (!p_no_cache) { if (!p_no_cache) {
_remove_from_loading_map(local_path); _remove_from_loading_map(local_path);
} }
ERR_EXPLAIN("Remapping '" + local_path + "'failed."); ERR_FAIL_V_MSG(RES(), "Remapping '" + local_path + "' failed.");
ERR_FAIL_V(RES());
} }
print_verbose("Loading resource: " + path); print_verbose("Loading resource: " + path);
@ -479,10 +472,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (!p_no_cache) { if (!p_no_cache) {
bool success = _add_to_loading_map(local_path); bool success = _add_to_loading_map(local_path);
if (!success) { ERR_FAIL_COND_V_MSG(!success, RES(), "Resource: '" + local_path + "' is already being loaded. Cyclic reference?");
ERR_EXPLAIN("Resource: '" + local_path + "' is already being loaded. Cyclic reference?");
ERR_FAIL_V(RES());
}
if (ResourceCache::has(local_path)) { if (ResourceCache::has(local_path)) {
@ -503,8 +493,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (!p_no_cache) { if (!p_no_cache) {
_remove_from_loading_map(local_path); _remove_from_loading_map(local_path);
} }
ERR_EXPLAIN("Remapping '" + local_path + "'failed."); ERR_FAIL_V_MSG(RES(), "Remapping '" + local_path + "' failed.");
ERR_FAIL_V(RES());
} }
print_verbose("Loading resource: " + path); print_verbose("Loading resource: " + path);
@ -534,12 +523,9 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
_remove_from_loading_map(local_path); _remove_from_loading_map(local_path);
} }
if (found) { ERR_FAIL_COND_V_MSG(found, Ref<ResourceInteractiveLoader>(), "Failed loading resource: " + path + ".");
ERR_EXPLAIN("Failed loading resource: " + path);
} else { ERR_FAIL_V_MSG(Ref<ResourceInteractiveLoader>(), "No loader found for resource: " + path + ".");
ERR_EXPLAIN("No loader found for resource: " + path);
}
ERR_FAIL_V(Ref<ResourceInteractiveLoader>());
} }
void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front) { void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front) {
@ -801,7 +787,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
if (err == ERR_FILE_EOF) { if (err == ERR_FILE_EOF) {
break; break;
} else if (err != OK) { } else if (err != OK) {
ERR_PRINTS("Parse error: " + p_path + ".remap:" + itos(lines) + " error: " + error_text); ERR_PRINTS("Parse error: " + p_path + ".remap:" + itos(lines) + " error: " + error_text + ".");
break; break;
} }
@ -932,13 +918,11 @@ bool ResourceLoader::add_custom_resource_format_loader(String script_path) {
Ref<Script> s = res; Ref<Script> s = res;
StringName ibt = s->get_instance_base_type(); StringName ibt = s->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "ResourceFormatLoader"); bool valid_type = ClassDB::is_parent_class(ibt, "ResourceFormatLoader");
ERR_EXPLAIN("Script does not inherit a CustomResourceLoader: " + script_path); ERR_FAIL_COND_V_MSG(!valid_type, false, "Script does not inherit a CustomResourceLoader: " + script_path + ".");
ERR_FAIL_COND_V(!valid_type, false);
Object *obj = ClassDB::instance(ibt); Object *obj = ClassDB::instance(ibt);
ERR_EXPLAIN("Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt)); ERR_FAIL_COND_V_MSG(obj == NULL, false, "Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt) + ".");
ERR_FAIL_COND_V(obj == NULL, false);
ResourceFormatLoader *crl = Object::cast_to<ResourceFormatLoader>(obj); ResourceFormatLoader *crl = Object::cast_to<ResourceFormatLoader>(obj);
crl->set_script(s.get_ref_ptr()); crl->set_script(s.get_ref_ptr());

View File

@ -214,13 +214,11 @@ bool ResourceSaver::add_custom_resource_format_saver(String script_path) {
Ref<Script> s = res; Ref<Script> s = res;
StringName ibt = s->get_instance_base_type(); StringName ibt = s->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "ResourceFormatSaver"); bool valid_type = ClassDB::is_parent_class(ibt, "ResourceFormatSaver");
ERR_EXPLAIN("Script does not inherit a CustomResourceSaver: " + script_path); ERR_FAIL_COND_V_MSG(!valid_type, false, "Script does not inherit a CustomResourceSaver: " + script_path + ".");
ERR_FAIL_COND_V(!valid_type, false);
Object *obj = ClassDB::instance(ibt); Object *obj = ClassDB::instance(ibt);
ERR_EXPLAIN("Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt)); ERR_FAIL_COND_V_MSG(obj == NULL, false, "Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt) + ".");
ERR_FAIL_COND_V(obj == NULL, false);
ResourceFormatSaver *crl = Object::cast_to<ResourceFormatSaver>(obj); ResourceFormatSaver *crl = Object::cast_to<ResourceFormatSaver>(obj);
crl->set_script(s.get_ref_ptr()); crl->set_script(s.get_ref_ptr());

View File

@ -67,8 +67,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
if (status == STATUS_READING_ID) { if (status == STATUS_READING_ID) {
memdelete(f); memdelete(f);
ERR_EXPLAIN(p_path + ":" + itos(line) + " Unexpected EOF while reading 'msgid' at file: "); ERR_FAIL_V_MSG(RES(), p_path + ":" + itos(line) + " Unexpected EOF while reading 'msgid' at file: ");
ERR_FAIL_V(RES());
} else { } else {
break; break;
} }
@ -79,8 +78,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
if (status == STATUS_READING_ID) { if (status == STATUS_READING_ID) {
memdelete(f); memdelete(f);
ERR_EXPLAIN(p_path + ":" + itos(line) + " Unexpected 'msgid', was expecting 'msgstr' while parsing: "); ERR_FAIL_V_MSG(RES(), p_path + ":" + itos(line) + " Unexpected 'msgid', was expecting 'msgstr' while parsing: ");
ERR_FAIL_V(RES());
} }
if (msg_id != "") { if (msg_id != "") {
@ -102,8 +100,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
if (status != STATUS_READING_ID) { if (status != STATUS_READING_ID) {
memdelete(f); memdelete(f);
ERR_EXPLAIN(p_path + ":" + itos(line) + " Unexpected 'msgstr', was expecting 'msgid' while parsing: "); ERR_FAIL_V_MSG(RES(), p_path + ":" + itos(line) + " Unexpected 'msgstr', was expecting 'msgid' while parsing: ");
ERR_FAIL_V(RES());
} }
l = l.substr(6, l.length()).strip_edges(); l = l.substr(6, l.length()).strip_edges();
@ -118,11 +115,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
continue; //nothing to read or comment continue; //nothing to read or comment
} }
if (!l.begins_with("\"") || status == STATUS_NONE) { ERR_FAIL_COND_V_MSG(!l.begins_with("\"") || status == STATUS_NONE, RES(), p_path + ":" + itos(line) + " Invalid line '" + l + "' while parsing: ");
//not a string? failure!
ERR_EXPLAIN(p_path + ":" + itos(line) + " Invalid line '" + l + "' while parsing: ");
ERR_FAIL_V(RES());
}
l = l.substr(1, l.length()); l = l.substr(1, l.length());
//find final quote //find final quote
@ -135,10 +128,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
} }
} }
if (end_pos == -1) { ERR_FAIL_COND_V_MSG(end_pos == -1, RES(), p_path + ":" + itos(line) + " Expected '\"' at end of message while parsing file: ");
ERR_EXPLAIN(p_path + ":" + itos(line) + " Expected '\"' at end of message while parsing file: ");
ERR_FAIL_V(RES());
}
l = l.substr(0, end_pos); l = l.substr(0, end_pos);
l = l.c_unescape(); l = l.c_unescape();
@ -163,10 +153,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
config = msg_str; config = msg_str;
} }
if (config == "") { ERR_FAIL_COND_V_MSG(config == "", RES(), "No config found in file: " + p_path + ".");
ERR_EXPLAIN("No config found in file: " + p_path);
ERR_FAIL_V(RES());
}
Vector<String> configs = config.split("\n"); Vector<String> configs = config.split("\n");
for (int i = 0; i < configs.size(); i++) { for (int i = 0; i < configs.size(); i++) {

View File

@ -443,10 +443,8 @@ String XMLParser::get_attribute_value(const String &p_name) const {
} }
} }
if (idx < 0) { ERR_FAIL_COND_V_MSG(idx < 0, "", "Attribute not found: " + p_name + ".");
ERR_EXPLAIN("Attribute not found: " + p_name);
}
ERR_FAIL_COND_V(idx < 0, "");
return attributes[idx].value; return attributes[idx].value;
} }

View File

@ -618,10 +618,7 @@ Basis::operator String() const {
Quat Basis::get_quat() const { Quat Basis::get_quat() const {
#ifdef MATH_CHECKS #ifdef MATH_CHECKS
if (!is_rotation()) { ERR_FAIL_COND_V_MSG(!is_rotation(), Quat(), "Basis must be normalized in order to be casted to a Quaternion. Use get_rotation_quat() or call orthonormalized() instead.");
ERR_EXPLAIN("Basis must be normalized in order to be casted to a Quaternion. Use get_rotation_quat() or call orthonormalized() instead.");
ERR_FAIL_V(Quat());
}
#endif #endif
/* Allow getting a quaternion from an unnormalized transform */ /* Allow getting a quaternion from an unnormalized transform */
Basis m = *this; Basis m = *this;

View File

@ -2161,10 +2161,8 @@ Error Expression::parse(const String &p_expression, const Vector<String> &p_inpu
} }
Variant Expression::execute(Array p_inputs, Object *p_base, bool p_show_error) { Variant Expression::execute(Array p_inputs, Object *p_base, bool p_show_error) {
if (error_set) {
ERR_EXPLAIN("There was previously a parse error: " + error_str); ERR_FAIL_COND_V_MSG(error_set, Variant(), "There was previously a parse error: " + error_str + ".");
ERR_FAIL_V(Variant());
}
execution_error = false; execution_error = false;
Variant output; Variant output;
@ -2173,10 +2171,7 @@ Variant Expression::execute(Array p_inputs, Object *p_base, bool p_show_error) {
if (err) { if (err) {
execution_error = true; execution_error = true;
error_str = error_txt; error_str = error_txt;
if (p_show_error) { ERR_FAIL_COND_V_MSG(p_show_error, Variant(), error_str);
ERR_EXPLAIN(error_str);
ERR_FAIL_V(Variant());
}
} }
return output; return output;

View File

@ -834,8 +834,7 @@ public:
static Vector<Vector<Point2> > offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) { static Vector<Vector<Point2> > offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
ERR_EXPLAIN("Attempt to offset a polyline like a polygon (use offset_polygon_2d instead)."); ERR_FAIL_COND_V_MSG(p_end_type == END_POLYGON, Vector<Vector<Point2> >(), "Attempt to offset a polyline like a polygon (use offset_polygon_2d instead).");
ERR_FAIL_COND_V(p_end_type == END_POLYGON, Vector<Vector<Point2> >());
return _polypath_offset(p_polygon, p_delta, p_join_type, p_end_type); return _polypath_offset(p_polygon, p_delta, p_join_type, p_end_type);
} }

View File

@ -564,10 +564,7 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const AABB &p_aabb) {
while (!base.encloses(p_aabb)) { while (!base.encloses(p_aabb)) {
if (base.size.x > OCTREE_SIZE_LIMIT) { ERR_FAIL_COND_MSG(base.size.x > OCTREE_SIZE_LIMIT, "Octree upper size limit reached, does the AABB supplied contain NAN?");
ERR_EXPLAIN("Octree upper size limit reeached, does the AABB supplied contain NAN?");
ERR_FAIL();
}
Octant *gp = memnew_allocator(Octant, AL); Octant *gp = memnew_allocator(Octant, AL);
octant_count++; octant_count++;

View File

@ -52,8 +52,7 @@ Error MessageQueue::push_call(ObjectID p_id, const StringName &p_method, const V
type = ObjectDB::get_instance(p_id)->get_class(); type = ObjectDB::get_instance(p_id)->get_class();
print_line("Failed method: " + type + ":" + p_method + " target ID: " + itos(p_id)); print_line("Failed method: " + type + ":" + p_method + " target ID: " + itos(p_id));
statistics(); statistics();
ERR_EXPLAIN("Message queue out of memory. Try increasing 'message_queue_size_kb' in project settings."); ERR_FAIL_V_MSG(ERR_OUT_OF_MEMORY, "Message queue out of memory. Try increasing 'message_queue_size_kb' in project settings.");
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
} }
Message *msg = memnew_placement(&buffer[buffer_end], Message); Message *msg = memnew_placement(&buffer[buffer_end], Message);
@ -103,8 +102,7 @@ Error MessageQueue::push_set(ObjectID p_id, const StringName &p_prop, const Vari
type = ObjectDB::get_instance(p_id)->get_class(); type = ObjectDB::get_instance(p_id)->get_class();
print_line("Failed set: " + type + ":" + p_prop + " target ID: " + itos(p_id)); print_line("Failed set: " + type + ":" + p_prop + " target ID: " + itos(p_id));
statistics(); statistics();
ERR_EXPLAIN("Message queue out of memory. Try increasing 'message_queue_size_kb' in project settings."); ERR_FAIL_V_MSG(ERR_OUT_OF_MEMORY, "Message queue out of memory. Try increasing 'message_queue_size_kb' in project settings.");
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
} }
Message *msg = memnew_placement(&buffer[buffer_end], Message); Message *msg = memnew_placement(&buffer[buffer_end], Message);
@ -136,8 +134,7 @@ Error MessageQueue::push_notification(ObjectID p_id, int p_notification) {
type = ObjectDB::get_instance(p_id)->get_class(); type = ObjectDB::get_instance(p_id)->get_class();
print_line("Failed notification: " + itos(p_notification) + " target ID: " + itos(p_id)); print_line("Failed notification: " + itos(p_notification) + " target ID: " + itos(p_id));
statistics(); statistics();
ERR_EXPLAIN("Message queue out of memory. Try increasing 'message_queue_size_kb' in project settings."); ERR_FAIL_V_MSG(ERR_OUT_OF_MEMORY, "Message queue out of memory. Try increasing 'message_queue_size_kb' in project settings.");
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
} }
Message *msg = memnew_placement(&buffer[buffer_end], Message); Message *msg = memnew_placement(&buffer[buffer_end], Message);
@ -256,7 +253,7 @@ void MessageQueue::_call_function(Object *p_target, const StringName &p_func, co
p_target->call(p_func, argptrs, p_argcount, ce); p_target->call(p_func, argptrs, p_argcount, ce);
if (p_show_error && ce.error != Variant::CallError::CALL_OK) { if (p_show_error && ce.error != Variant::CallError::CALL_OK) {
ERR_PRINTS("Error calling deferred method: " + Variant::get_call_error_text(p_target, p_func, argptrs, p_argcount, ce)); ERR_PRINTS("Error calling deferred method: " + Variant::get_call_error_text(p_target, p_func, argptrs, p_argcount, ce) + ".");
} }
} }

View File

@ -375,8 +375,7 @@ NodePath::NodePath(const String &p_path) {
if (str == "") { if (str == "") {
if (path[i] == 0) continue; // Allow end-of-path : if (path[i] == 0) continue; // Allow end-of-path :
ERR_EXPLAIN("Invalid NodePath: " + p_path); ERR_FAIL_MSG("Invalid NodePath: " + p_path + ".");
ERR_FAIL();
} }
subpath.push_back(str); subpath.push_back(str);

View File

@ -709,20 +709,17 @@ static void _test_call_error(const StringName &p_func, const Variant::CallError
break; break;
case Variant::CallError::CALL_ERROR_INVALID_ARGUMENT: { case Variant::CallError::CALL_ERROR_INVALID_ARGUMENT: {
ERR_EXPLAIN("Error Calling Function: " + String(p_func) + " - Invalid type for argument " + itos(error.argument) + ", expected " + Variant::get_type_name(error.expected)); ERR_FAIL_MSG("Error calling function: " + String(p_func) + " - Invalid type for argument " + itos(error.argument) + ", expected " + Variant::get_type_name(error.expected) + ".");
ERR_FAIL();
break; break;
} }
case Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: { case Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
ERR_EXPLAIN("Error Calling Function: " + String(p_func) + " - Too many arguments, expected " + itos(error.argument)); ERR_FAIL_MSG("Error calling function: " + String(p_func) + " - Too many arguments, expected " + itos(error.argument) + ".");
ERR_FAIL();
break; break;
} }
case Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: { case Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
ERR_EXPLAIN("Error Calling Function: " + String(p_func) + " - Too few arguments, expected " + itos(error.argument)); ERR_FAIL_MSG("Error calling function: " + String(p_func) + " - Too few arguments, expected " + itos(error.argument) + ".");
ERR_FAIL();
break; break;
} }
case Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL: case Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL:
@ -739,15 +736,9 @@ void Object::call_multilevel(const StringName &p_method, const Variant **p_args,
if (p_method == CoreStringNames::get_singleton()->_free) { if (p_method == CoreStringNames::get_singleton()->_free) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (Object::cast_to<Reference>(this)) { ERR_FAIL_COND_MSG(Object::cast_to<Reference>(this), "Can't 'free' a reference.");
ERR_EXPLAIN("Can't 'free' a reference.");
ERR_FAIL();
}
if (_lock_index.get() > 1) { ERR_FAIL_COND_MSG(_lock_index.get() > 1, "Object is locked and can't be freed.");
ERR_EXPLAIN("Object is locked and can't be freed.");
ERR_FAIL();
}
#endif #endif
//must be here, must be before everything, //must be here, must be before everything,
@ -835,8 +826,7 @@ Variant Object::callv(const StringName &p_method, const Array &p_args) {
Variant::CallError ce; Variant::CallError ce;
Variant ret = call(p_method, argptrs, p_args.size(), ce); Variant ret = call(p_method, argptrs, p_args.size(), ce);
if (ce.error != Variant::CallError::CALL_OK) { if (ce.error != Variant::CallError::CALL_OK) {
ERR_EXPLAIN("Error calling method from 'callv': " + Variant::get_call_error_text(this, p_method, argptrs, p_args.size(), ce)); ERR_FAIL_V_MSG(Variant(), "Error calling method from 'callv': " + Variant::get_call_error_text(this, p_method, argptrs, p_args.size(), ce) + ".");
ERR_FAIL_V(Variant());
} }
return ret; return ret;
} }
@ -888,15 +878,13 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a
if (Object::cast_to<Reference>(this)) { if (Object::cast_to<Reference>(this)) {
r_error.argument = 0; r_error.argument = 0;
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
ERR_EXPLAIN("Can't 'free' a reference."); ERR_FAIL_V_MSG(Variant(), "Can't 'free' a reference.");
ERR_FAIL_V(Variant());
} }
if (_lock_index.get() > 1) { if (_lock_index.get() > 1) {
r_error.argument = 0; r_error.argument = 0;
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
ERR_EXPLAIN("Object is locked and can't be freed."); ERR_FAIL_V_MSG(Variant(), "Object is locked and can't be freed.");
ERR_FAIL_V(Variant());
} }
#endif #endif
@ -1172,10 +1160,7 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_name); bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_name);
//check in script //check in script
if (!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name)) { ERR_FAIL_COND_V_MSG(!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name), ERR_UNAVAILABLE, "Can't emit non-existing signal " + String("\"") + p_name + "\".");
ERR_EXPLAIN("Can't emit non-existing signal " + String("\"") + p_name + "\".");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
#endif #endif
//not connected? just return //not connected? just return
return ERR_UNAVAILABLE; return ERR_UNAVAILABLE;
@ -1240,7 +1225,7 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
if (ce.error == Variant::CallError::CALL_ERROR_INVALID_METHOD && !ClassDB::class_exists(target->get_class_name())) { if (ce.error == Variant::CallError::CALL_ERROR_INVALID_METHOD && !ClassDB::class_exists(target->get_class_name())) {
//most likely object is not initialized yet, do not throw error. //most likely object is not initialized yet, do not throw error.
} else { } else {
ERR_PRINTS("Error calling method from signal '" + String(p_name) + "': " + Variant::get_call_error_text(target, c.method, args, argc, ce)); ERR_PRINTS("Error calling method from signal '" + String(p_name) + "': " + Variant::get_call_error_text(target, c.method, args, argc, ce) + ".");
err = ERR_METHOD_NOT_FOUND; err = ERR_METHOD_NOT_FOUND;
} }
} }
@ -1463,10 +1448,8 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
#endif #endif
} }
if (!signal_is_valid) { ERR_FAIL_COND_V_MSG(!signal_is_valid, ERR_INVALID_PARAMETER, "In Object of type '" + String(get_class()) + "': Attempt to connect nonexistent signal '" + p_signal + "' to method '" + p_to_object->get_class() + "." + p_to_method + "'.");
ERR_EXPLAIN("In Object of type '" + String(get_class()) + "': Attempt to connect nonexistent signal '" + p_signal + "' to method '" + p_to_object->get_class() + "." + p_to_method + "'");
ERR_FAIL_V(ERR_INVALID_PARAMETER);
}
signal_map[p_signal] = Signal(); signal_map[p_signal] = Signal();
s = &signal_map[p_signal]; s = &signal_map[p_signal];
} }
@ -1477,8 +1460,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
s->slot_map[target].reference_count++; s->slot_map[target].reference_count++;
return OK; return OK;
} else { } else {
ERR_EXPLAIN("Signal '" + p_signal + "' is already connected to given method '" + p_to_method + "' in that object."); ERR_FAIL_V_MSG(ERR_INVALID_PARAMETER, "Signal '" + p_signal + "' is already connected to given method '" + p_to_method + "' in that object.");
ERR_FAIL_V(ERR_INVALID_PARAMETER);
} }
} }
@ -1514,8 +1496,7 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const
if (!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal)) if (!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal))
return false; return false;
ERR_EXPLAIN("Nonexistent signal: " + p_signal); ERR_FAIL_V_MSG(false, "Nonexistent signal: " + p_signal + ".");
ERR_FAIL_V(false);
} }
Signal::Target target(p_to_object->get_instance_id(), p_to_method); Signal::Target target(p_to_object->get_instance_id(), p_to_method);
@ -1533,21 +1514,13 @@ void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const
ERR_FAIL_NULL(p_to_object); ERR_FAIL_NULL(p_to_object);
Signal *s = signal_map.getptr(p_signal); Signal *s = signal_map.getptr(p_signal);
if (!s) { ERR_FAIL_COND_MSG(!s, "Nonexistent signal: " + p_signal + ".");
ERR_EXPLAIN("Nonexistent signal: " + p_signal);
ERR_FAIL(); ERR_FAIL_COND_MSG(s->lock > 0, "Attempt to disconnect signal '" + p_signal + "' while emitting (locks: " + itos(s->lock) + ").");
}
if (s->lock > 0) {
ERR_EXPLAIN("Attempt to disconnect signal '" + p_signal + "' while emitting (locks: " + itos(s->lock) + ")");
ERR_FAIL();
}
Signal::Target target(p_to_object->get_instance_id(), p_to_method); Signal::Target target(p_to_object->get_instance_id(), p_to_method);
if (!s->slot_map.has(target)) { ERR_FAIL_COND_MSG(!s->slot_map.has(target), "Disconnecting nonexistent signal '" + p_signal + "', slot: " + itos(target._id) + ":" + target.method + ".");
ERR_EXPLAIN("Disconnecting nonexistent signal '" + p_signal + "', slot: " + itos(target._id) + ":" + target.method);
ERR_FAIL();
}
Signal::Slot *slot = &s->slot_map[target]; Signal::Slot *slot = &s->slot_map[target];
@ -1974,10 +1947,7 @@ Object::~Object() {
Signal *s = &signal_map[*S]; Signal *s = &signal_map[*S];
if (s->lock) { ERR_CONTINUE_MSG(s->lock > 0, "Attempt to delete an object in the middle of a signal emission from it.");
ERR_EXPLAIN("Attempt to delete an object in the middle of a signal emission from it");
ERR_CONTINUE(s->lock > 0);
}
//brute force disconnect for performance //brute force disconnect for performance
int slot_count = s->slot_map.size(); int slot_count = s->slot_map.size();

View File

@ -599,8 +599,7 @@ Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_err
if (r_error) { // if error requested, do not throw error if (r_error) { // if error requested, do not throw error
return Vector<uint8_t>(); return Vector<uint8_t>();
} }
ERR_EXPLAIN("Can't open file from path: " + String(p_path)); ERR_FAIL_V_MSG(Vector<uint8_t>(), "Can't open file from path: " + String(p_path) + ".");
ERR_FAIL_V(Vector<uint8_t>());
} }
Vector<uint8_t> data; Vector<uint8_t> data;
data.resize(f->get_len()); data.resize(f->get_len());
@ -620,8 +619,7 @@ String FileAccess::get_file_as_string(const String &p_path, Error *r_error) {
if (r_error) { if (r_error) {
return String(); return String();
} }
ERR_EXPLAIN("Can't get file as string from path: " + String(p_path)); ERR_FAIL_V_MSG(String(), "Can't get file as string from path: " + String(p_path) + ".");
ERR_FAIL_V(String());
} }
String ret; String ret;

View File

@ -268,8 +268,7 @@ void OS::print_all_resources(String p_to_file) {
_OSPRF = FileAccess::open(p_to_file, FileAccess::WRITE, &err); _OSPRF = FileAccess::open(p_to_file, FileAccess::WRITE, &err);
if (err != OK) { if (err != OK) {
_OSPRF = NULL; _OSPRF = NULL;
ERR_EXPLAIN("Can't print all resources to file: " + String(p_to_file)); ERR_FAIL_MSG("Can't print all resources to file: " + String(p_to_file) + ".");
ERR_FAIL();
} }
} }
@ -487,10 +486,7 @@ void OS::_ensure_user_data_dir() {
da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = da->make_dir_recursive(dd); Error err = da->make_dir_recursive(dd);
if (err != OK) { ERR_FAIL_COND_MSG(err != OK, "Error attempting to create data dir: " + dd + ".");
ERR_EXPLAIN("Error attempting to create data dir: " + dd);
}
ERR_FAIL_COND(err != OK);
memdelete(da); memdelete(da);
} }

View File

@ -204,10 +204,8 @@ PoolAllocator::ID PoolAllocator::alloc(int p_size) {
/* Then search again */ /* Then search again */
if (!find_hole(&new_entry_indices_pos, size_to_alloc)) { if (!find_hole(&new_entry_indices_pos, size_to_alloc)) {
mt_unlock(); mt_unlock();
ERR_EXPLAIN("Memory can't be compacted further"); ERR_FAIL_V_MSG(POOL_ALLOCATOR_INVALID_ID, "Memory can't be compacted further.");
ERR_FAIL_V(POOL_ALLOCATOR_INVALID_ID);
} }
} }
@ -217,8 +215,7 @@ PoolAllocator::ID PoolAllocator::alloc(int p_size) {
if (!found_free_entry) { if (!found_free_entry) {
mt_unlock(); mt_unlock();
ERR_EXPLAIN("No free entry found in PoolAllocator"); ERR_FAIL_V_MSG(POOL_ALLOCATOR_INVALID_ID, "No free entry found in PoolAllocator.");
ERR_FAIL_V(POOL_ALLOCATOR_INVALID_ID);
} }
/* move all entry indices up, make room for this one */ /* move all entry indices up, make room for this one */

View File

@ -66,6 +66,5 @@ void MemoryPool::cleanup() {
memdelete_arr(allocs); memdelete_arr(allocs);
memdelete(alloc_mutex); memdelete(alloc_mutex);
ERR_EXPLAINC("There are still MemoryPool allocs in use at exit!"); ERR_FAIL_COND_MSG(allocs_used > 0, "There are still MemoryPool allocs in use at exit!");
ERR_FAIL_COND(allocs_used > 0);
} }

View File

@ -98,8 +98,7 @@ class PoolVector {
MemoryPool::alloc_mutex->lock(); MemoryPool::alloc_mutex->lock();
if (MemoryPool::allocs_used == MemoryPool::alloc_count) { if (MemoryPool::allocs_used == MemoryPool::alloc_count) {
MemoryPool::alloc_mutex->unlock(); MemoryPool::alloc_mutex->unlock();
ERR_EXPLAINC("All memory pool allocations are in use, can't COW."); ERR_FAIL_MSG("All memory pool allocations are in use, can't COW.");
ERR_FAIL();
} }
MemoryPool::Alloc *old_alloc = alloc; MemoryPool::Alloc *old_alloc = alloc;
@ -520,8 +519,7 @@ Error PoolVector<T>::resize(int p_size) {
MemoryPool::alloc_mutex->lock(); MemoryPool::alloc_mutex->lock();
if (MemoryPool::allocs_used == MemoryPool::alloc_count) { if (MemoryPool::allocs_used == MemoryPool::alloc_count) {
MemoryPool::alloc_mutex->unlock(); MemoryPool::alloc_mutex->unlock();
ERR_EXPLAINC("All memory pool allocations are in use."); ERR_FAIL_V_MSG(ERR_OUT_OF_MEMORY, "All memory pool allocations are in use.");
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
} }
//take one from the free list //take one from the free list

View File

@ -500,8 +500,7 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) {
if (hdr[0] != 'E' || hdr[1] != 'C' || hdr[2] != 'F' || hdr[3] != 'G') { if (hdr[0] != 'E' || hdr[1] != 'C' || hdr[2] != 'F' || hdr[3] != 'G') {
memdelete(f); memdelete(f);
ERR_EXPLAIN("Corrupted header in binary project.binary (not ECFG)"); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Corrupted header in binary project.binary (not ECFG).");
ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
uint32_t count = f->get_32(); uint32_t count = f->get_32();
@ -522,8 +521,7 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) {
f->get_buffer(d.ptrw(), vlen); f->get_buffer(d.ptrw(), vlen);
Variant value; Variant value;
err = decode_variant(value, d.ptr(), d.size(), NULL, true); err = decode_variant(value, d.ptr(), d.size(), NULL, true);
ERR_EXPLAIN("Error decoding property: " + key); ERR_CONTINUE_MSG(err != OK, "Error decoding property: " + key + ".");
ERR_CONTINUE(err != OK);
set(key, value); set(key, value);
} }
@ -577,8 +575,7 @@ Error ProjectSettings::_load_settings_text(const String &p_path) {
config_version = value; config_version = value;
if (config_version > CONFIG_VERSION) { if (config_version > CONFIG_VERSION) {
memdelete(f); memdelete(f);
ERR_EXPLAIN(vformat("Can't open project at '%s', its `config_version` (%d) is from a more recent and incompatible version of the engine. Expected config version: %d.", p_path, config_version, CONFIG_VERSION)); ERR_FAIL_V_MSG(ERR_FILE_CANT_OPEN, vformat("Can't open project at '%s', its `config_version` (%d) is from a more recent and incompatible version of the engine. Expected config version: %d.", p_path, config_version, CONFIG_VERSION));
ERR_FAIL_V(ERR_FILE_CANT_OPEN);
} }
} else { } else {
if (section == String()) { if (section == String()) {
@ -645,11 +642,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str
Error err; Error err;
FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err != OK) { ERR_FAIL_COND_V_MSG(err != OK, err, "Couldn't save project.binary at " + p_file + ".");
ERR_EXPLAIN("Couldn't save project.binary at " + p_file);
ERR_FAIL_COND_V(err, err);
}
uint8_t hdr[4] = { 'E', 'C', 'F', 'G' }; uint8_t hdr[4] = { 'E', 'C', 'F', 'G' };
file->store_buffer(hdr, 4); file->store_buffer(hdr, 4);
@ -738,10 +731,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
Error err; Error err;
FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err) { ERR_FAIL_COND_V_MSG(err != OK, err, "Couldn't save project.godot - " + p_file + ".");
ERR_EXPLAIN("Couldn't save project.godot - " + p_file);
ERR_FAIL_COND_V(err, err);
}
file->store_line("; Engine configuration file."); file->store_line("; Engine configuration file.");
file->store_line("; It's best edited using the editor UI and not directly,"); file->store_line("; It's best edited using the editor UI and not directly,");
@ -872,8 +862,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
return _save_settings_binary(p_path, props, p_custom, custom_features); return _save_settings_binary(p_path, props, p_custom, custom_features);
else { else {
ERR_EXPLAIN("Unknown config file format: " + p_path); ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unknown config file format: " + p_path + ".");
ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
} }
} }

View File

@ -75,8 +75,7 @@ void Resource::set_path(const String &p_path, bool p_take_over) {
bool exists = ResourceCache::resources.has(p_path); bool exists = ResourceCache::resources.has(p_path);
ResourceCache::lock->read_unlock(); ResourceCache::lock->read_unlock();
ERR_EXPLAIN("Another resource is loaded from path: " + p_path + " (possible cyclic resource inclusion)"); ERR_FAIL_COND_MSG(exists, "Another resource is loaded from path: " + p_path + " (possible cyclic resource inclusion).");
ERR_FAIL_COND(exists);
} }
} }
path_cache = p_path; path_cache = p_path;
@ -277,8 +276,7 @@ void Resource::notify_change_to_owners() {
for (Set<ObjectID>::Element *E = owners.front(); E; E = E->next()) { for (Set<ObjectID>::Element *E = owners.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->get()); Object *obj = ObjectDB::get_instance(E->get());
ERR_EXPLAIN("Object was deleted, while still owning a resource"); ERR_CONTINUE_MSG(!obj, "Object was deleted, while still owning a resource."); //wtf
ERR_CONTINUE(!obj); //wtf
//TODO store string //TODO store string
obj->call("resource_changed", RES(this)); obj->call("resource_changed", RES(this));
} }
@ -427,7 +425,7 @@ Resource::~Resource() {
ResourceCache::lock->write_unlock(); ResourceCache::lock->write_unlock();
} }
if (owners.size()) { if (owners.size()) {
WARN_PRINT("Resource is still owned"); WARN_PRINT("Resource is still owned.");
} }
} }

View File

@ -89,7 +89,7 @@ Error ScriptDebuggerRemote::connect_to_host(const String &p_host, uint16_t p_por
if (tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED) { if (tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
ERR_PRINTS("Remote Debugger: Unable to connect. Status: " + String::num(tcp_client->get_status())); ERR_PRINTS("Remote Debugger: Unable to connect. Status: " + String::num(tcp_client->get_status()) + ".");
return FAILED; return FAILED;
}; };
@ -110,7 +110,7 @@ void ScriptDebuggerRemote::_put_variable(const String &p_name, const Variant &p_
int len = 0; int len = 0;
Error err = encode_variant(var, NULL, len, true); Error err = encode_variant(var, NULL, len, true);
if (err != OK) if (err != OK)
ERR_PRINT("Failed to encode variant"); ERR_PRINT("Failed to encode variant.");
if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size
packet_peer_stream->put_var(Variant()); packet_peer_stream->put_var(Variant());
@ -134,10 +134,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
//this function is called when there is a debugger break (bug on script) //this function is called when there is a debugger break (bug on script)
//or when execution is paused from editor //or when execution is paused from editor
if (!tcp_client->is_connected_to_host()) { ERR_FAIL_COND_MSG(!tcp_client->is_connected_to_host(), "Script Debugger failed to connect, but being used anyway.");
ERR_EXPLAIN("Script Debugger failed to connect, but being used anyway.");
ERR_FAIL();
}
packet_peer_stream->put_var("debug_enter"); packet_peer_stream->put_var("debug_enter");
packet_peer_stream->put_var(2); packet_peer_stream->put_var(2);

View File

@ -848,8 +848,7 @@ void Translation::set_locale(const String &p_locale) {
if (!TranslationServer::is_locale_valid(univ_locale)) { if (!TranslationServer::is_locale_valid(univ_locale)) {
String trimmed_locale = get_trimmed_locale(univ_locale); String trimmed_locale = get_trimmed_locale(univ_locale);
ERR_EXPLAIN("Invalid locale: " + trimmed_locale); ERR_FAIL_COND_MSG(!TranslationServer::is_locale_valid(trimmed_locale), "Invalid locale: " + trimmed_locale + ".");
ERR_FAIL_COND(!TranslationServer::is_locale_valid(trimmed_locale));
locale = trimmed_locale; locale = trimmed_locale;
} else { } else {

View File

@ -1740,10 +1740,7 @@ Variant::operator RID() const {
} else if (type == OBJECT && _get_obj().obj) { } else if (type == OBJECT && _get_obj().obj) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (ScriptDebugger::get_singleton()) { if (ScriptDebugger::get_singleton()) {
if (!ObjectDB::instance_validate(_get_obj().obj)) { ERR_FAIL_COND_V_MSG(!ObjectDB::instance_validate(_get_obj().obj), RID(), "Invalid pointer (object was deleted).");
ERR_EXPLAIN("Invalid pointer (object was deleted)");
ERR_FAIL_V(RID());
};
}; };
#endif #endif
Variant::CallError ce; Variant::CallError ce;

View File

@ -584,8 +584,7 @@ struct _VariantCall {
if (buffer_size < 0) { if (buffer_size < 0) {
r_ret = decompressed; r_ret = decompressed;
ERR_EXPLAIN("Decompression buffer size is less than zero"); ERR_FAIL_MSG("Decompression buffer size is less than zero.");
ERR_FAIL();
} }
decompressed.resize(buffer_size); decompressed.resize(buffer_size);

View File

@ -1265,14 +1265,11 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) { void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) {
if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) { if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
ERR_PRINT_ONCE("Cannot use screen texture copying in render target set to render direct to screen"); ERR_PRINT_ONCE("Cannot use screen texture copying in render target set to render direct to screen.");
return; return;
} }
if (storage->frame.current_rt->copy_screen_effect.color == 0) { ERR_FAIL_COND_MSG(storage->frame.current_rt->copy_screen_effect.color == 0, "Can't use screen texture copying in a render target configured without copy buffers.");
ERR_EXPLAIN("Can't use screen texture copying in a render target configured without copy buffers");
ERR_FAIL();
}
glDisable(GL_BLEND); glDisable(GL_BLEND);

View File

@ -882,8 +882,7 @@ RID RasterizerSceneGLES2::light_instance_create(RID p_light) {
if (!light_instance->light_ptr) { if (!light_instance->light_ptr) {
memdelete(light_instance); memdelete(light_instance);
ERR_EXPLAIN("Condition ' !light_instance->light_ptr ' is true."); ERR_FAIL_V_MSG(RID(), "Condition ' !light_instance->light_ptr ' is true.");
ERR_FAIL_V(RID());
} }
light_instance->self = light_instance_owner.make_rid(light_instance); light_instance->self = light_instance_owner.make_rid(light_instance);

View File

@ -2171,8 +2171,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
//must have index and bones, both. //must have index and bones, both.
{ {
uint32_t bones_weight = VS::ARRAY_FORMAT_BONES | VS::ARRAY_FORMAT_WEIGHTS; uint32_t bones_weight = VS::ARRAY_FORMAT_BONES | VS::ARRAY_FORMAT_WEIGHTS;
ERR_EXPLAIN("Array must have both bones and weights in format or none."); ERR_FAIL_COND_MSG((p_format & bones_weight) && (p_format & bones_weight) != bones_weight, "Array must have both bones and weights in format or none.");
ERR_FAIL_COND((p_format & bones_weight) && (p_format & bones_weight) != bones_weight);
} }
//bool has_morph = p_blend_shapes.size(); //bool has_morph = p_blend_shapes.size();

View File

@ -1156,10 +1156,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) { void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) {
if (storage->frame.current_rt->effects.mip_maps[0].sizes.size() == 0) { ERR_FAIL_COND_MSG(storage->frame.current_rt->effects.mip_maps[0].sizes.size() == 0, "Can't use screen texture copying in a render target configured without copy buffers.");
ERR_EXPLAIN("Can't use screen texture copying in a render target configured without copy buffers");
ERR_FAIL();
}
glDisable(GL_BLEND); glDisable(GL_BLEND);

View File

@ -1008,8 +1008,7 @@ RID RasterizerSceneGLES3::light_instance_create(RID p_light) {
if (!light_instance->light_ptr) { if (!light_instance->light_ptr) {
memdelete(light_instance); memdelete(light_instance);
ERR_EXPLAIN("Condition ' !light_instance->light_ptr ' is true."); ERR_FAIL_V_MSG(RID(), "Condition ' !light_instance->light_ptr ' is true.");
ERR_FAIL_V(RID());
} }
light_instance->self = light_instance_owner.make_rid(light_instance); light_instance->self = light_instance_owner.make_rid(light_instance);

View File

@ -3191,8 +3191,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
//must have index and bones, both. //must have index and bones, both.
{ {
uint32_t bones_weight = VS::ARRAY_FORMAT_BONES | VS::ARRAY_FORMAT_WEIGHTS; uint32_t bones_weight = VS::ARRAY_FORMAT_BONES | VS::ARRAY_FORMAT_WEIGHTS;
ERR_EXPLAIN("Array must have both bones and weights in format or none."); ERR_FAIL_COND_MSG((p_format & bones_weight) && (p_format & bones_weight) != bones_weight, "Array must have both bones and weights in format or none.");
ERR_FAIL_COND((p_format & bones_weight) && (p_format & bones_weight) != bones_weight);
} }
//bool has_morph = p_blend_shapes.size(); //bool has_morph = p_blend_shapes.size();

View File

@ -97,7 +97,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
break; break;
default: default:
png_image_free(&png_img); // only required when we return before finish_read png_image_free(&png_img); // only required when we return before finish_read
ERR_PRINT("Unsupported png format"); ERR_PRINT("Unsupported png format.");
return ERR_UNAVAILABLE; return ERR_UNAVAILABLE;
} }
@ -179,10 +179,9 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
ERR_FAIL_COND_V(check_error(png_img), FAILED); ERR_FAIL_COND_V(check_error(png_img), FAILED);
} }
if (!success) { if (!success) {
if (compressed_size <= png_size_estimate) {
// buffer was big enough, must be some other error // buffer was big enough, must be some other error
ERR_FAIL_V(FAILED); ERR_FAIL_COND_V(compressed_size <= png_size_estimate, FAILED);
}
// write failed due to buffer size, resize and retry // write failed due to buffer size, resize and retry
Error err = p_buffer.resize(buffer_offset + compressed_size); Error err = p_buffer.resize(buffer_offset + compressed_size);

View File

@ -39,9 +39,8 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32
Ref<ImageTexture> texture = p_resource; Ref<ImageTexture> texture = p_resource;
ERR_FAIL_COND_V(!texture.is_valid(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(!texture.is_valid(), ERR_INVALID_PARAMETER, "Can't save invalid texture as PNG.");
ERR_EXPLAIN("Can't save empty texture as PNG"); ERR_FAIL_COND_V_MSG(!texture->get_width(), ERR_INVALID_PARAMETER, "Can't save empty texture as PNG.");
ERR_FAIL_COND_V(!texture->get_width() || !texture->get_height(), ERR_INVALID_PARAMETER);
Ref<Image> img = texture->get_data(); Ref<Image> img = texture->get_data();

View File

@ -288,8 +288,7 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
if (!err) { if (!err) {
return flags.st_mtime; return flags.st_mtime;
} else { } else {
ERR_EXPLAIN("Failed to get modified time for: " + p_file); ERR_FAIL_V_MSG(0, "Failed to get modified time for: " + p_file + ".");
ERR_FAIL_V(0);
}; };
} }
@ -302,8 +301,7 @@ uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) {
if (!err) { if (!err) {
return flags.st_mode & 0x7FF; //only permissions return flags.st_mode & 0x7FF; //only permissions
} else { } else {
ERR_EXPLAIN("Failed to get unix permissions for: " + p_file); ERR_FAIL_V_MSG(0, "Failed to get unix permissions for: " + p_file + ".");
ERR_FAIL_V(0);
}; };
} }

View File

@ -184,9 +184,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
continue; // will go back and alloc the right size continue; // will go back and alloc the right size
}; };
ERR_EXPLAIN("Call to GetAdaptersAddresses failed with error " + itos(err)); ERR_FAIL_MSG("Call to GetAdaptersAddresses failed with error " + itos(err) + ".");
ERR_FAIL();
return;
}; };
IP_ADAPTER_ADDRESSES *adapter = addrs; IP_ADAPTER_ADDRESSES *adapter = addrs;

View File

@ -72,8 +72,7 @@ static double _clock_scale = 0;
static void _setup_clock() { static void _setup_clock() {
mach_timebase_info_data_t info; mach_timebase_info_data_t info;
kern_return_t ret = mach_timebase_info(&info); kern_return_t ret = mach_timebase_info(&info);
ERR_EXPLAIN("OS CLOCK IS NOT WORKING!"); ERR_FAIL_COND_MSG(ret != 0, "OS CLOCK IS NOT WORKING!");
ERR_FAIL_COND(ret != 0);
_clock_scale = ((double)info.numer / (double)info.denom) / 1000.0; _clock_scale = ((double)info.numer / (double)info.denom) / 1000.0;
_clock_start = mach_absolute_time() * _clock_scale; _clock_start = mach_absolute_time() * _clock_scale;
} }
@ -85,8 +84,7 @@ static void _setup_clock() {
#endif #endif
static void _setup_clock() { static void _setup_clock() {
struct timespec tv_now = { 0, 0 }; struct timespec tv_now = { 0, 0 };
ERR_EXPLAIN("OS CLOCK IS NOT WORKING!"); ERR_FAIL_COND_MSG(clock_gettime(GODOT_CLOCK, &tv_now) != 0, "OS CLOCK IS NOT WORKING!");
ERR_FAIL_COND(clock_gettime(GODOT_CLOCK, &tv_now) != 0);
_clock_start = ((uint64_t)tv_now.tv_nsec / 1000L) + (uint64_t)tv_now.tv_sec * 1000000L; _clock_start = ((uint64_t)tv_now.tv_nsec / 1000L) + (uint64_t)tv_now.tv_sec * 1000000L;
} }
#endif #endif
@ -420,10 +418,7 @@ Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle
} }
p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
if (!p_library_handle) { ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + p_path + ". Error: " + dlerror());
ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror());
ERR_FAIL_V(ERR_CANT_OPEN);
}
return OK; return OK;
} }
@ -442,12 +437,9 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S
error = dlerror(); error = dlerror();
if (error != NULL) { if (error != NULL) {
if (!p_optional) { ERR_FAIL_COND_V_MSG(!p_optional, ERR_CANT_RESOLVE, "Can't resolve symbol " + p_name + ". Error: " + error + ".");
ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + error);
ERR_FAIL_V(ERR_CANT_RESOLVE); return ERR_CANT_RESOLVE;
} else {
return ERR_CANT_RESOLVE;
}
} }
return OK; return OK;
} }

View File

@ -296,8 +296,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
} }
hr = p_device->audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, streamflags, p_capture ? REFTIMES_PER_SEC : 0, 0, pwfex, NULL); hr = p_device->audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, streamflags, p_capture ? REFTIMES_PER_SEC : 0, 0, pwfex, NULL);
ERR_EXPLAIN("WASAPI: Initialize failed with error 0x" + String::num_uint64(hr, 16)); ERR_FAIL_COND_V_MSG(hr != S_OK, ERR_CANT_OPEN, "WASAPI: Initialize failed with error 0x" + String::num_uint64(hr, 16) + ".");
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
if (p_capture) { if (p_capture) {
hr = p_device->audio_client->GetService(IID_IAudioCaptureClient, (void **)&p_device->capture_client); hr = p_device->audio_client->GetService(IID_IAudioCaptureClient, (void **)&p_device->capture_client);

View File

@ -172,8 +172,6 @@ void FileAccessWindows::close() {
} }
save_path = ""; save_path = "";
ERR_FAIL_COND(rename_error);
} }
} }
@ -334,8 +332,7 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {
return st.st_mtime; return st.st_mtime;
} else { } else {
ERR_EXPLAIN("Failed to get modified time for: " + file); ERR_FAIL_V_MSG(0, "Failed to get modified time for: " + file + ".");
ERR_FAIL_V(0);
} }
} }

View File

@ -1903,8 +1903,7 @@ void Collada::_parse_animation(XMLParser &parser) {
Vector<float> &output = float_sources[output_id]; Vector<float> &output = float_sources[output_id];
ERR_EXPLAIN("Wrong number of keys in output"); ERR_CONTINUE_MSG((output.size() / stride) != key_count, "Wrong number of keys in output.");
ERR_CONTINUE((output.size() / stride) != key_count);
for (int j = 0; j < key_count; j++) { for (int j = 0; j < key_count; j++) {
track.keys.write[j].data.resize(output_len); track.keys.write[j].data.resize(output_len);
@ -2447,8 +2446,7 @@ void Collada::_find_morph_nodes(VisualScene *p_vscene, Node *p_node) {
state.morph_ownership_map[base] = nj->id; state.morph_ownership_map[base] = nj->id;
break; break;
} else { } else {
ERR_EXPLAIN("Invalid scene"); ERR_FAIL_MSG("Invalid scene.");
ERR_FAIL();
} }
} }
} }

View File

@ -720,8 +720,7 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &
methods.push_back(method); methods.push_back(method);
} else { } else {
ERR_EXPLAIN("Invalid tag in doc file: " + parser->get_node_name()); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + parser->get_node_name() + ".");
ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == section) } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == section)
@ -841,8 +840,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
if (parser->get_node_type() == XMLParser::NODE_TEXT) if (parser->get_node_type() == XMLParser::NODE_TEXT)
c.tutorials.push_back(parser->get_node_data().strip_edges()); c.tutorials.push_back(parser->get_node_data().strip_edges());
} else { } else {
ERR_EXPLAIN("Invalid tag in doc file: " + name3); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "tutorials") } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "tutorials")
break; //end of <tutorials> break; //end of <tutorials>
@ -883,8 +881,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
prop2.description = parser->get_node_data(); prop2.description = parser->get_node_data();
c.properties.push_back(prop2); c.properties.push_back(prop2);
} else { } else {
ERR_EXPLAIN("Invalid tag in doc file: " + name3); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "members") } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "members")
@ -912,8 +909,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
prop2.description = parser->get_node_data(); prop2.description = parser->get_node_data();
c.theme_properties.push_back(prop2); c.theme_properties.push_back(prop2);
} else { } else {
ERR_EXPLAIN("Invalid tag in doc file: " + name3); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "theme_items") } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "theme_items")
@ -943,8 +939,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
constant2.description = parser->get_node_data(); constant2.description = parser->get_node_data();
c.constants.push_back(constant2); c.constants.push_back(constant2);
} else { } else {
ERR_EXPLAIN("Invalid tag in doc file: " + name3); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "constants") } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "constants")
@ -953,8 +948,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
} else { } else {
ERR_EXPLAIN("Invalid tag in doc file: " + name2); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name2 + ".");
ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "class") } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "class")
@ -991,10 +985,8 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
Error err; Error err;
String save_file = save_path.plus_file(c.name + ".xml"); String save_file = save_path.plus_file(c.name + ".xml");
FileAccessRef f = FileAccess::open(save_file, FileAccess::WRITE, &err); FileAccessRef f = FileAccess::open(save_file, FileAccess::WRITE, &err);
if (err) {
ERR_EXPLAIN("Can't write doc file: " + save_file); ERR_CONTINUE_MSG(err != OK, "Can't write doc file: " + save_file + ".");
ERR_CONTINUE(err);
}
_write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); _write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");

View File

@ -315,8 +315,7 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) {
Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
RES res = ResourceLoader::load(p_path); RES res = ResourceLoader::load(p_path);
ERR_EXPLAIN("Can't autoload: " + p_path); ERR_FAIL_COND_V_MSG(res.is_null(), NULL, "Can't autoload: " + p_path + ".");
ERR_FAIL_COND_V(res.is_null(), NULL);
Node *n = NULL; Node *n = NULL;
if (res->is_class("PackedScene")) { if (res->is_class("PackedScene")) {
Ref<PackedScene> ps = res; Ref<PackedScene> ps = res;
@ -325,20 +324,17 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
Ref<Script> s = res; Ref<Script> s = res;
StringName ibt = s->get_instance_base_type(); StringName ibt = s->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node"); bool valid_type = ClassDB::is_parent_class(ibt, "Node");
ERR_EXPLAIN("Script does not inherit a Node: " + p_path); ERR_FAIL_COND_V_MSG(!valid_type, NULL, "Script does not inherit a Node: " + p_path + ".");
ERR_FAIL_COND_V(!valid_type, NULL);
Object *obj = ClassDB::instance(ibt); Object *obj = ClassDB::instance(ibt);
ERR_EXPLAIN("Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt)); ERR_FAIL_COND_V_MSG(obj == NULL, NULL, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + ".");
ERR_FAIL_COND_V(obj == NULL, NULL);
n = Object::cast_to<Node>(obj); n = Object::cast_to<Node>(obj);
n->set_script(s.get_ref_ptr()); n->set_script(s.get_ref_ptr());
} }
ERR_EXPLAIN("Path in autoload not a node or script: " + p_path); ERR_FAIL_COND_V_MSG(!n, NULL, "Path in autoload not a node or script: " + p_path + ".");
ERR_FAIL_COND_V(!n, NULL);
return n; return n;
} }

View File

@ -1011,7 +1011,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c
if (!ftmp) { if (!ftmp) {
memdelete(f); memdelete(f);
DirAccess::remove_file_or_error(tmppath); DirAccess::remove_file_or_error(tmppath);
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't open file to read from path: " + String(tmppath)); ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't open file to read from path: " + String(tmppath) + ".");
} }
const int bufsize = 16384; const int bufsize = 16384;

View File

@ -1930,8 +1930,7 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
Error err = da->make_dir(".import"); Error err = da->make_dir(".import");
if (err) { if (err) {
memdelete(da); memdelete(da);
ERR_EXPLAIN("Failed to create 'res://.import' folder."); ERR_FAIL_MSG("Failed to create 'res://.import' folder.");
ERR_FAIL();
} }
} }
memdelete(da); memdelete(da);

View File

@ -2795,8 +2795,7 @@ void EditorNode::select_editor_by_name(const String &p_name) {
} }
} }
ERR_EXPLAIN("The editor name '" + p_name + "' was not found."); ERR_FAIL_MSG("The editor name '" + p_name + "' was not found.");
ERR_FAIL();
} }
void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) { void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
@ -4797,8 +4796,7 @@ void EditorNode::remove_control_from_dock(Control *p_control) {
} }
} }
ERR_EXPLAIN("Control was not in dock"); ERR_FAIL_COND_MSG(!dock, "Control was not in dock.");
ERR_FAIL_COND(!dock);
dock->remove_child(p_control); dock->remove_child(p_control);
_update_dock_slots_visibility(); _update_dock_slots_visibility();

View File

@ -46,8 +46,7 @@ bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
if (get_script_instance() && get_script_instance()->has_method("handles")) { if (get_script_instance() && get_script_instance()->has_method("handles")) {
return get_script_instance()->call("handles", p_type); return get_script_instance()->call("handles", p_type);
} }
ERR_EXPLAIN("EditorResourcePreviewGenerator::handles needs to be overridden"); ERR_FAIL_V_MSG(false, "EditorResourcePreviewGenerator::handles needs to be overridden.");
ERR_FAIL_V(false);
} }
Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const { Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const {
@ -55,8 +54,7 @@ Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from, const S
if (get_script_instance() && get_script_instance()->has_method("generate")) { if (get_script_instance() && get_script_instance()->has_method("generate")) {
return get_script_instance()->call("generate", p_from, p_size); return get_script_instance()->call("generate", p_from, p_size);
} }
ERR_EXPLAIN("EditorResourcePreviewGenerator::generate needs to be overridden"); ERR_FAIL_V_MSG(Ref<Texture>(), "EditorResourcePreviewGenerator::generate needs to be overridden.");
ERR_FAIL_V(Ref<Texture>());
} }
Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const { Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const {

View File

@ -1451,10 +1451,7 @@ void EditorSettings::add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcu
bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const { bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const {
const Map<String, Ref<ShortCut> >::Element *E = shortcuts.find(p_name); const Map<String, Ref<ShortCut> >::Element *E = shortcuts.find(p_name);
if (!E) { ERR_FAIL_COND_V_MSG(!E, false, "Unknown Shortcut: " + p_name + ".");
ERR_EXPLAIN("Unknown Shortcut: " + p_name);
ERR_FAIL_V(false);
}
return E->get()->is_shortcut(p_event); return E->get()->is_shortcut(p_event);
} }
@ -1483,10 +1480,8 @@ Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {
} }
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path); Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (!sc.is_valid()) {
ERR_EXPLAIN("Used ED_GET_SHORTCUT with invalid shortcut: " + p_path); ERR_FAIL_COND_V_MSG(!sc.is_valid(), sc, "Used ED_GET_SHORTCUT with invalid shortcut: " + p_path + ".");
ERR_FAIL_COND_V(!sc.is_valid(), sc);
}
return sc; return sc;
} }

View File

@ -321,8 +321,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
if (!f) { if (!f) {
ret = unzGoToNextFile(pkg); ret = unzGoToNextFile(pkg);
fc++; fc++;
ERR_EXPLAIN("Can't open file from path: " + String(to_write)); ERR_CONTINUE_MSG(true, "Can't open file from path: " + String(to_write) + ".");
ERR_CONTINUE(true);
} }
f->store_buffer(data.ptr(), data.size()); f->store_buffer(data.ptr(), data.size());
@ -591,8 +590,7 @@ Error ExportTemplateManager::install_android_template() {
zlib_filefunc_def io = zipio_create_io_from_file(&src_f); zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(source_zip.utf8().get_data(), &io); unzFile pkg = unzOpen2(source_zip.utf8().get_data(), &io);
ERR_EXPLAIN("Android sources not in zip format"); ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in zip format.");
ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN);
int ret = unzGoToFirstFile(pkg); int ret = unzGoToFirstFile(pkg);

View File

@ -83,11 +83,8 @@ void FileTypeCache::save() {
GLOBAL_LOCK_FUNCTION GLOBAL_LOCK_FUNCTION
String project = ProjectSettings::get_singleton()->get_resource_path(); String project = ProjectSettings::get_singleton()->get_resource_path();
FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::WRITE); FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::WRITE);
if (!f) {
ERR_EXPLAIN(TTR("Can't open file_type_cache.cch for writing, not saving file type cache!")); ERR_FAIL_COND_MSG(!f, "Can't open file_type_cache.cch for writing, not saving file type cache!");
ERR_FAIL();
}
const String *K = NULL; const String *K = NULL;

View File

@ -453,8 +453,7 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa
path = target_path + "/"; path = target_path + "/";
} else { } else {
memdelete(dirAccess); memdelete(dirAccess);
ERR_EXPLAIN(vformat(TTR("Cannot navigate to '%s' as it has not been found in the file system!"), p_path)); ERR_FAIL_MSG(vformat("Cannot navigate to '%s' as it has not been found in the file system!", p_path));
ERR_FAIL();
} }
memdelete(dirAccess); memdelete(dirAccess);
} }

View File

@ -1204,10 +1204,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
} }
} }
if (ngsource != "") { ERR_FAIL_COND_V_MSG(ngsource != "", ERR_INVALID_DATA, "Controller instance source '" + ngsource + "' is neither skin or morph!");
ERR_EXPLAIN("Controller Instance Source '" + ngsource + "' is neither skin or morph!");
ERR_FAIL_V(ERR_INVALID_DATA);
}
} else { } else {
meshid = ng2->source; meshid = ng2->source;
@ -1608,7 +1605,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
} }
if (xform_idx == -1) { if (xform_idx == -1) {
WARN_PRINTS("Collada: Couldn't find matching node " + at.target + " xform for track " + at.param); WARN_PRINTS("Collada: Couldn't find matching node " + at.target + " xform for track " + at.param + ".");
continue; continue;
} }
@ -1630,8 +1627,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
} else if (data.size() == xf.data.size()) { } else if (data.size() == xf.data.size()) {
xf.data = data; xf.data = data;
} else { } else {
ERR_EXPLAIN("Component " + at.component + " has datasize " + itos(data.size()) + ", xfdatasize " + itos(xf.data.size())); ERR_CONTINUE_MSG(data.size() != xf.data.size(), "Component " + at.component + " has datasize " + itos(data.size()) + ", xfdatasize " + itos(xf.data.size()) + ".");
ERR_CONTINUE(data.size() != xf.data.size());
} }
} }

View File

@ -1544,8 +1544,7 @@ Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) {
camera.fov_size = 10; camera.fov_size = 10;
} }
} else { } else {
ERR_EXPLAIN("Camera should be in 'orthographic' or 'perspective'"); ERR_FAIL_V_MSG(ERR_PARSE_ERROR, "Camera should be in 'orthographic' or 'perspective'");
ERR_FAIL_V(ERR_PARSE_ERROR);
} }
state.cameras.push_back(camera); state.cameras.push_back(camera);

View File

@ -101,8 +101,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
for (int i = 1; i < line.size(); i++) { for (int i = 1; i < line.size(); i++) {
String locale = line[i]; String locale = line[i];
ERR_EXPLAIN("Error importing CSV translation: '" + locale + "' is not a valid locale"); ERR_FAIL_COND_V_MSG(!TranslationServer::is_locale_valid(locale), ERR_PARSE_ERROR, "Error importing CSV translation: '" + locale + "' is not a valid locale.");
ERR_FAIL_COND_V(!TranslationServer::is_locale_valid(locale), ERR_PARSE_ERROR);
locales.push_back(locale); locales.push_back(locale);
Ref<Translation> translation; Ref<Translation> translation;

View File

@ -45,8 +45,7 @@ uint32_t EditorOBJImporter::get_import_flags() const {
static Error _parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps) { static Error _parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps) {
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
ERR_EXPLAIN(vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path)); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path));
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
Ref<SpatialMaterial> current; Ref<SpatialMaterial> current;
String current_name; String current_name;
@ -207,8 +206,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, List<String> *r_missing_deps) { static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, List<String> *r_missing_deps) {
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
ERR_EXPLAIN(vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path)); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path));
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
Ref<ArrayMesh> mesh; Ref<ArrayMesh> mesh;
mesh.instance(); mesh.instance();

View File

@ -123,8 +123,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
file->close(); file->close();
memdelete(file); memdelete(file);
ERR_EXPLAIN("Not a WAV file (no WAVE RIFF Header)"); ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Not a WAV file (no WAVE RIFF header).");
ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
} }
int format_bits = 0; int format_bits = 0;
@ -166,16 +165,14 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
if (compression_code != 1 && compression_code != 3) { if (compression_code != 1 && compression_code != 3) {
file->close(); file->close();
memdelete(file); memdelete(file);
ERR_EXPLAIN("Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead."); ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead.");
ERR_FAIL_V(ERR_INVALID_DATA);
} }
format_channels = file->get_16(); format_channels = file->get_16();
if (format_channels != 1 && format_channels != 2) { if (format_channels != 1 && format_channels != 2) {
file->close(); file->close();
memdelete(file); memdelete(file);
ERR_EXPLAIN("Format not supported for WAVE file (not stereo or mono)."); ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Format not supported for WAVE file (not stereo or mono).");
ERR_FAIL_V(ERR_INVALID_DATA);
} }
format_freq = file->get_32(); //sampling rate format_freq = file->get_32(); //sampling rate
@ -187,8 +184,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
if (format_bits % 8 || format_bits == 0) { if (format_bits % 8 || format_bits == 0) {
file->close(); file->close();
memdelete(file); memdelete(file);
ERR_EXPLAIN("Invalid amount of bits in the sample (should be one of 8, 16, 24 or 32)."); ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Invalid amount of bits in the sample (should be one of 8, 16, 24 or 32).");
ERR_FAIL_V(ERR_INVALID_DATA);
} }
/* Don't need anything else, continue */ /* Don't need anything else, continue */
@ -258,8 +254,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
if (file->eof_reached()) { if (file->eof_reached()) {
file->close(); file->close();
memdelete(file); memdelete(file);
ERR_EXPLAIN("Premature end of file."); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Premature end of file.");
ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
} }

View File

@ -87,8 +87,7 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
Ref<Image> img; Ref<Image> img;
img.instance(); img.instance();
Error err = ImageLoader::load_image(source_emission_file, img); Error err = ImageLoader::load_image(source_emission_file, img);
ERR_EXPLAIN(TTR("Error loading image:") + " " + source_emission_file); ERR_FAIL_COND_MSG(err != OK, "Error loading image: " + source_emission_file + ".");
ERR_FAIL_COND(err != OK);
if (img->is_compressed()) { if (img->is_compressed()) {
img->decompress(); img->decompress();
@ -196,8 +195,7 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
valid_normals.resize(vpc); valid_normals.resize(vpc);
} }
ERR_EXPLAIN(TTR("No pixels with transparency > 128 in image...")); ERR_FAIL_COND_MSG(valid_positions.size() == 0, "No pixels with transparency > 128 in image...");
ERR_FAIL_COND(valid_positions.size() == 0);
if (capture_colors) { if (capture_colors) {
PoolColorArray pca; PoolColorArray pca;

View File

@ -147,9 +147,8 @@ void MultiMeshEditor::_populate() {
w.release(); w.release();
PoolVector<Face3> faces = geometry; PoolVector<Face3> faces = geometry;
ERR_EXPLAIN(TTR("Parent has no solid faces to populate."));
int facecount = faces.size(); int facecount = faces.size();
ERR_FAIL_COND(!facecount); ERR_FAIL_COND_MSG(!facecount, "Parent has no solid faces to populate.");
PoolVector<Face3>::Read r = faces.read(); PoolVector<Face3>::Read r = faces.read();
@ -164,10 +163,8 @@ void MultiMeshEditor::_populate() {
area_accum += area; area_accum += area;
} }
ERR_EXPLAIN(TTR("Couldn't map area.")); ERR_FAIL_COND_MSG(triangle_area_map.size() == 0, "Couldn't map area.");
ERR_FAIL_COND(triangle_area_map.size() == 0); ERR_FAIL_COND_MSG(area_accum == 0, "Couldn't map area.");
ERR_EXPLAIN(TTR("Couldn't map area."));
ERR_FAIL_COND(area_accum == 0);
Ref<MultiMesh> multimesh = memnew(MultiMesh); Ref<MultiMesh> multimesh = memnew(MultiMesh);
multimesh->set_mesh(mesh); multimesh->set_mesh(mesh);

View File

@ -160,8 +160,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
Ref<Image> img; Ref<Image> img;
img.instance(); img.instance();
Error err = ImageLoader::load_image(source_emission_file, img); Error err = ImageLoader::load_image(source_emission_file, img);
ERR_EXPLAIN(TTR("Error loading image:") + " " + source_emission_file); ERR_FAIL_COND_MSG(err != OK, "Error loading image: " + source_emission_file + ".");
ERR_FAIL_COND(err != OK);
if (img->is_compressed()) { if (img->is_compressed()) {
img->decompress(); img->decompress();
@ -269,8 +268,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
valid_normals.resize(vpc); valid_normals.resize(vpc);
} }
ERR_EXPLAIN(TTR("No pixels with transparency > 128 in image...")); ERR_FAIL_COND_MSG(valid_positions.size() == 0, "No pixels with transparency > 128 in image...");
ERR_FAIL_COND(valid_positions.size() == 0);
PoolVector<uint8_t> texdata; PoolVector<uint8_t> texdata;

View File

@ -191,11 +191,9 @@ void ThemeEditor::_save_template_cbk(String fname) {
} }
FileAccess *file = FileAccess::open(filename, FileAccess::WRITE); FileAccess *file = FileAccess::open(filename, FileAccess::WRITE);
if (!file) {
ERR_EXPLAIN(TTR("Can't save theme to file:") + " " + filename); ERR_FAIL_COND_MSG(!file, "Can't save theme to file: " + filename + ".");
return;
}
file->store_line("; ******************* "); file->store_line("; ******************* ");
file->store_line("; Template Theme File "); file->store_line("; Template Theme File ");
file->store_line("; ******************* "); file->store_line("; ******************* ");

View File

@ -646,8 +646,7 @@ void TileSetEditor::_on_textures_added(const PoolStringArray &p_paths) {
for (int i = 0; i < p_paths.size(); i++) { for (int i = 0; i < p_paths.size(); i++) {
Ref<Texture> t = Ref<Texture>(ResourceLoader::load(p_paths[i])); Ref<Texture> t = Ref<Texture>(ResourceLoader::load(p_paths[i]));
ERR_EXPLAIN("'" + p_paths[i] + "' is not a valid texture."); ERR_CONTINUE_MSG(!t.is_valid(), "'" + p_paths[i] + "' is not a valid texture.");
ERR_CONTINUE(!t.is_valid());
if (texture_map.has(t->get_rid())) { if (texture_map.has(t->get_rid())) {
invalid_count++; invalid_count++;

View File

@ -986,9 +986,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} else { } else {
new_node = Object::cast_to<Node>(ClassDB::instance(selected_favorite_root)); new_node = Object::cast_to<Node>(ClassDB::instance(selected_favorite_root));
} }
if (!new_node) { if (!new_node) {
ERR_EXPLAIN("Creating root from favorite '" + selected_favorite_root + "' failed. Creating 'Node' instead.");
new_node = memnew(Node); new_node = memnew(Node);
ERR_PRINTS("Creating root from favorite '" + selected_favorite_root + "' failed. Creating 'Node' instead.");
} }
} else { } else {
switch (p_tool) { switch (p_tool) {
@ -1537,10 +1538,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
Node *validate = new_parent; Node *validate = new_parent;
while (validate) { while (validate) {
if (p_nodes.find(validate) != -1) { ERR_FAIL_COND_MSG(p_nodes.find(validate) != -1, "Selection changed at some point.. can't reparent.");
ERR_EXPLAIN("Selection changed at some point.. can't reparent");
ERR_FAIL();
}
validate = validate->get_parent(); validate = validate->get_parent();
} }
//ok all valid //ok all valid
@ -2253,8 +2251,7 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) {
//drop at above selected node //drop at above selected node
if (to_node == EditorNode::get_singleton()->get_edited_scene()) { if (to_node == EditorNode::get_singleton()->get_edited_scene()) {
to_node = NULL; to_node = NULL;
ERR_EXPLAIN("Cannot perform drop above the root node!"); ERR_FAIL_MSG("Cannot perform drop above the root node!");
ERR_FAIL();
} }
to_pos = to_node->get_index(); to_pos = to_node->get_index();