Added some obvious errors explanations

This commit is contained in:
qarmin 2019-09-25 10:28:50 +02:00
parent e9f49a6d5a
commit 17732fe698
125 changed files with 435 additions and 458 deletions

View File

@ -145,13 +145,13 @@ _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) {
ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path: " + String(p_path) + "."); ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path '" + String(p_path) + "'.");
return ResourceSaver::save(p_path, p_resource, p_flags); return ResourceSaver::save(p_path, p_resource, p_flags);
} }
PoolVector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) { PoolVector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) {
ERR_FAIL_COND_V(p_resource.is_null(), PoolVector<String>()); ERR_FAIL_COND_V_MSG(p_resource.is_null(), PoolVector<String>(), "It's not a reference to a valid Resource object.");
List<String> exts; List<String> exts;
ResourceSaver::get_recognized_extensions(p_resource, &exts); ResourceSaver::get_recognized_extensions(p_resource, &exts);
PoolVector<String> ret; PoolVector<String> ret;
@ -755,7 +755,7 @@ int64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
ERR_FAIL_COND_V_MSG(month > 12 || month == 0, 0, "Invalid month value of: " + itos(month) + "."); ERR_FAIL_COND_V_MSG(month > 12 || month == 0, 0, "Invalid month value of: " + itos(month) + ".");
// Do this check after month is tested as valid // Do this check after month is tested as valid
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_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.");
// 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;
@ -1866,92 +1866,92 @@ bool _File::is_open() const {
} }
String _File::get_path() const { String _File::get_path() const {
ERR_FAIL_COND_V(!f, ""); ERR_FAIL_COND_V_MSG(!f, "", "File must be opened before use.");
return f->get_path(); return f->get_path();
} }
String _File::get_path_absolute() const { String _File::get_path_absolute() const {
ERR_FAIL_COND_V(!f, ""); ERR_FAIL_COND_V_MSG(!f, "", "File must be opened before use.");
return f->get_path_absolute(); return f->get_path_absolute();
} }
void _File::seek(int64_t p_position) { void _File::seek(int64_t p_position) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->seek(p_position); f->seek(p_position);
} }
void _File::seek_end(int64_t p_position) { void _File::seek_end(int64_t p_position) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->seek_end(p_position); f->seek_end(p_position);
} }
int64_t _File::get_position() const { int64_t _File::get_position() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_position(); return f->get_position();
} }
int64_t _File::get_len() const { int64_t _File::get_len() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_len(); return f->get_len();
} }
bool _File::eof_reached() const { bool _File::eof_reached() const {
ERR_FAIL_COND_V(!f, false); ERR_FAIL_COND_V_MSG(!f, false, "File must be opened before use.");
return f->eof_reached(); return f->eof_reached();
} }
uint8_t _File::get_8() const { uint8_t _File::get_8() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_8(); return f->get_8();
} }
uint16_t _File::get_16() const { uint16_t _File::get_16() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_16(); return f->get_16();
} }
uint32_t _File::get_32() const { uint32_t _File::get_32() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_32(); return f->get_32();
} }
uint64_t _File::get_64() const { uint64_t _File::get_64() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_64(); return f->get_64();
} }
float _File::get_float() const { float _File::get_float() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_float(); return f->get_float();
} }
double _File::get_double() const { double _File::get_double() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_double(); return f->get_double();
} }
real_t _File::get_real() const { real_t _File::get_real() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_real(); return f->get_real();
} }
PoolVector<uint8_t> _File::get_buffer(int p_length) const { PoolVector<uint8_t> _File::get_buffer(int p_length) const {
PoolVector<uint8_t> data; PoolVector<uint8_t> data;
ERR_FAIL_COND_V(!f, data); ERR_FAIL_COND_V_MSG(!f, data, "File must be opened before use.");
ERR_FAIL_COND_V(p_length < 0, data); ERR_FAIL_COND_V_MSG(p_length < 0, data, "Length of buffer cannot be smaller than 0.");
if (p_length == 0) if (p_length == 0)
return data; return data;
Error err = data.resize(p_length); Error err = data.resize(p_length);
ERR_FAIL_COND_V(err != OK, data); ERR_FAIL_COND_V_MSG(err != OK, data, "Can't resize data to " + itos(p_length) + " elements.");
PoolVector<uint8_t>::Write w = data.write(); PoolVector<uint8_t>::Write w = data.write();
int len = f->get_buffer(&w[0], p_length); int len = f->get_buffer(&w[0], p_length);
@ -1967,7 +1967,7 @@ PoolVector<uint8_t> _File::get_buffer(int p_length) const {
String _File::get_as_text() const { String _File::get_as_text() const {
ERR_FAIL_COND_V(!f, String()); ERR_FAIL_COND_V_MSG(!f, String(), "File must be opened before use.");
String text; String text;
size_t original_pos = f->get_position(); size_t original_pos = f->get_position();
@ -1997,12 +1997,12 @@ String _File::get_sha256(const String &p_path) const {
String _File::get_line() const { String _File::get_line() const {
ERR_FAIL_COND_V(!f, String()); ERR_FAIL_COND_V_MSG(!f, String(), "File must be opened before use.");
return f->get_line(); return f->get_line();
} }
Vector<String> _File::get_csv_line(const String &p_delim) const { Vector<String> _File::get_csv_line(const String &p_delim) const {
ERR_FAIL_COND_V(!f, Vector<String>()); ERR_FAIL_COND_V_MSG(!f, Vector<String>(), "File must be opened before use.");
return f->get_csv_line(p_delim); return f->get_csv_line(p_delim);
} }
@ -2031,83 +2031,83 @@ Error _File::get_error() const {
void _File::store_8(uint8_t p_dest) { void _File::store_8(uint8_t p_dest) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_8(p_dest); f->store_8(p_dest);
} }
void _File::store_16(uint16_t p_dest) { void _File::store_16(uint16_t p_dest) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_16(p_dest); f->store_16(p_dest);
} }
void _File::store_32(uint32_t p_dest) { void _File::store_32(uint32_t p_dest) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_32(p_dest); f->store_32(p_dest);
} }
void _File::store_64(uint64_t p_dest) { void _File::store_64(uint64_t p_dest) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_64(p_dest); f->store_64(p_dest);
} }
void _File::store_float(float p_dest) { void _File::store_float(float p_dest) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_float(p_dest); f->store_float(p_dest);
} }
void _File::store_double(double p_dest) { void _File::store_double(double p_dest) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_double(p_dest); f->store_double(p_dest);
} }
void _File::store_real(real_t p_real) { void _File::store_real(real_t p_real) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_real(p_real); f->store_real(p_real);
} }
void _File::store_string(const String &p_string) { void _File::store_string(const String &p_string) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_string(p_string); f->store_string(p_string);
} }
void _File::store_pascal_string(const String &p_string) { void _File::store_pascal_string(const String &p_string) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_pascal_string(p_string); f->store_pascal_string(p_string);
}; };
String _File::get_pascal_string() { String _File::get_pascal_string() {
ERR_FAIL_COND_V(!f, ""); ERR_FAIL_COND_V_MSG(!f, "", "File must be opened before use.");
return f->get_pascal_string(); return f->get_pascal_string();
}; };
void _File::store_line(const String &p_string) { void _File::store_line(const String &p_string) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_line(p_string); f->store_line(p_string);
} }
void _File::store_csv_line(const Vector<String> &p_values, const String &p_delim) { void _File::store_csv_line(const Vector<String> &p_values, const String &p_delim) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_csv_line(p_values, p_delim); f->store_csv_line(p_values, p_delim);
} }
void _File::store_buffer(const PoolVector<uint8_t> &p_buffer) { void _File::store_buffer(const PoolVector<uint8_t> &p_buffer) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
int len = p_buffer.size(); int len = p_buffer.size();
if (len == 0) if (len == 0)
@ -2125,17 +2125,17 @@ bool _File::file_exists(const String &p_name) const {
void _File::store_var(const Variant &p_var, bool p_full_objects) { void _File::store_var(const Variant &p_var, bool p_full_objects) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
int len; int len;
Error err = encode_variant(p_var, NULL, len, p_full_objects); Error err = encode_variant(p_var, NULL, len, p_full_objects);
ERR_FAIL_COND(err != OK); ERR_FAIL_COND_MSG(err != OK, "Error when trying to encode Variant.");
PoolVector<uint8_t> buff; PoolVector<uint8_t> buff;
buff.resize(len); buff.resize(len);
PoolVector<uint8_t>::Write w = buff.write(); PoolVector<uint8_t>::Write w = buff.write();
err = encode_variant(p_var, &w[0], len, p_full_objects); err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND(err != OK); ERR_FAIL_COND_MSG(err != OK, "Error when trying to encode Variant.");
w.release(); w.release();
store_32(len); store_32(len);
@ -2144,7 +2144,7 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) {
Variant _File::get_var(bool p_allow_objects) const { Variant _File::get_var(bool p_allow_objects) const {
ERR_FAIL_COND_V(!f, Variant()); ERR_FAIL_COND_V_MSG(!f, Variant(), "File must be opened before use.");
uint32_t len = get_32(); uint32_t len = get_32();
PoolVector<uint8_t> buff = get_buffer(len); PoolVector<uint8_t> buff = get_buffer(len);
ERR_FAIL_COND_V((uint32_t)buff.size() != len, Variant()); ERR_FAIL_COND_V((uint32_t)buff.size() != len, Variant());
@ -2153,7 +2153,7 @@ Variant _File::get_var(bool p_allow_objects) const {
Variant v; Variant v;
Error err = decode_variant(v, &r[0], len, NULL, p_allow_objects); Error err = decode_variant(v, &r[0], len, NULL, p_allow_objects);
ERR_FAIL_COND_V(err != OK, Variant()); ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to encode Variant.");
return v; return v;
} }
@ -2258,7 +2258,7 @@ Error _Directory::open(const String &p_path) {
Error _Directory::list_dir_begin(bool p_skip_navigational, bool p_skip_hidden) { Error _Directory::list_dir_begin(bool p_skip_navigational, bool p_skip_hidden) {
ERR_FAIL_COND_V(!d, ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
_list_skip_navigational = p_skip_navigational; _list_skip_navigational = p_skip_navigational;
_list_skip_hidden = p_skip_hidden; _list_skip_hidden = p_skip_hidden;
@ -2268,7 +2268,7 @@ Error _Directory::list_dir_begin(bool p_skip_navigational, bool p_skip_hidden) {
String _Directory::get_next() { String _Directory::get_next() {
ERR_FAIL_COND_V(!d, ""); ERR_FAIL_COND_V_MSG(!d, "", "Directory must be opened before use.");
String next = d->get_next(); String next = d->get_next();
while (next != "" && ((_list_skip_navigational && (next == "." || next == "..")) || (_list_skip_hidden && d->current_is_hidden()))) { while (next != "" && ((_list_skip_navigational && (next == "." || next == "..")) || (_list_skip_hidden && d->current_is_hidden()))) {
@ -2279,44 +2279,44 @@ String _Directory::get_next() {
} }
bool _Directory::current_is_dir() const { bool _Directory::current_is_dir() const {
ERR_FAIL_COND_V(!d, false); ERR_FAIL_COND_V_MSG(!d, false, "Directory must be opened before use.");
return d->current_is_dir(); return d->current_is_dir();
} }
void _Directory::list_dir_end() { void _Directory::list_dir_end() {
ERR_FAIL_COND(!d); ERR_FAIL_COND_MSG(!d, "Directory must be opened before use.");
d->list_dir_end(); d->list_dir_end();
} }
int _Directory::get_drive_count() { int _Directory::get_drive_count() {
ERR_FAIL_COND_V(!d, 0); ERR_FAIL_COND_V_MSG(!d, 0, "Directory must be opened before use.");
return d->get_drive_count(); return d->get_drive_count();
} }
String _Directory::get_drive(int p_drive) { String _Directory::get_drive(int p_drive) {
ERR_FAIL_COND_V(!d, ""); ERR_FAIL_COND_V_MSG(!d, "", "Directory must be opened before use.");
return d->get_drive(p_drive); return d->get_drive(p_drive);
} }
int _Directory::get_current_drive() { int _Directory::get_current_drive() {
ERR_FAIL_COND_V(!d, 0); ERR_FAIL_COND_V_MSG(!d, 0, "Directory must be opened before use.");
return d->get_current_drive(); return d->get_current_drive();
} }
Error _Directory::change_dir(String p_dir) { Error _Directory::change_dir(String p_dir) {
ERR_FAIL_COND_V(!d, ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
return d->change_dir(p_dir); return d->change_dir(p_dir);
} }
String _Directory::get_current_dir() { String _Directory::get_current_dir() {
ERR_FAIL_COND_V(!d, ""); ERR_FAIL_COND_V_MSG(!d, "", "Directory must be opened before use.");
return d->get_current_dir(); return d->get_current_dir();
} }
Error _Directory::make_dir(String p_dir) { Error _Directory::make_dir(String p_dir) {
ERR_FAIL_COND_V(!d, ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_dir.is_rel_path()) { if (!p_dir.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_dir); DirAccess *d = DirAccess::create_for_path(p_dir);
Error err = d->make_dir(p_dir); Error err = d->make_dir(p_dir);
@ -2327,7 +2327,7 @@ Error _Directory::make_dir(String p_dir) {
} }
Error _Directory::make_dir_recursive(String p_dir) { Error _Directory::make_dir_recursive(String p_dir) {
ERR_FAIL_COND_V(!d, ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_dir.is_rel_path()) { if (!p_dir.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_dir); DirAccess *d = DirAccess::create_for_path(p_dir);
Error err = d->make_dir_recursive(p_dir); Error err = d->make_dir_recursive(p_dir);
@ -2339,7 +2339,7 @@ Error _Directory::make_dir_recursive(String p_dir) {
bool _Directory::file_exists(String p_file) { bool _Directory::file_exists(String p_file) {
ERR_FAIL_COND_V(!d, false); ERR_FAIL_COND_V_MSG(!d, false, "Directory must be opened before use.");
if (!p_file.is_rel_path()) { if (!p_file.is_rel_path()) {
return FileAccess::exists(p_file); return FileAccess::exists(p_file);
@ -2349,7 +2349,7 @@ bool _Directory::file_exists(String p_file) {
} }
bool _Directory::dir_exists(String p_dir) { bool _Directory::dir_exists(String p_dir) {
ERR_FAIL_COND_V(!d, false); ERR_FAIL_COND_V_MSG(!d, false, "Directory must be opened before use.");
if (!p_dir.is_rel_path()) { if (!p_dir.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_dir); DirAccess *d = DirAccess::create_for_path(p_dir);
@ -2364,18 +2364,18 @@ bool _Directory::dir_exists(String p_dir) {
int _Directory::get_space_left() { int _Directory::get_space_left() {
ERR_FAIL_COND_V(!d, 0); ERR_FAIL_COND_V_MSG(!d, 0, "Directory must be opened before use.");
return d->get_space_left() / 1024 * 1024; //return value in megabytes, given binding is int return d->get_space_left() / 1024 * 1024; //return value in megabytes, given binding is int
} }
Error _Directory::copy(String p_from, String p_to) { Error _Directory::copy(String p_from, String p_to) {
ERR_FAIL_COND_V(!d, ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
return d->copy(p_from, p_to); return d->copy(p_from, p_to);
} }
Error _Directory::rename(String p_from, String p_to) { Error _Directory::rename(String p_from, String p_to) {
ERR_FAIL_COND_V(!d, ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_from.is_rel_path()) { if (!p_from.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_from); DirAccess *d = DirAccess::create_for_path(p_from);
Error err = d->rename(p_from, p_to); Error err = d->rename(p_from, p_to);
@ -2387,7 +2387,7 @@ Error _Directory::rename(String p_from, String p_to) {
} }
Error _Directory::remove(String p_name) { Error _Directory::remove(String p_name) {
ERR_FAIL_COND_V(!d, ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_name.is_rel_path()) { if (!p_name.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_name); DirAccess *d = DirAccess::create_for_path(p_name);
Error err = d->remove(p_name); Error err = d->remove(p_name);
@ -2442,14 +2442,14 @@ String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects)
int len; int len;
Error err = encode_variant(p_var, NULL, len, p_full_objects); Error err = encode_variant(p_var, NULL, len, p_full_objects);
ERR_FAIL_COND_V(err != OK, ""); ERR_FAIL_COND_V_MSG(err != OK, "", "Error when trying to encode Variant.");
PoolVector<uint8_t> buff; PoolVector<uint8_t> buff;
buff.resize(len); buff.resize(len);
PoolVector<uint8_t>::Write w = buff.write(); PoolVector<uint8_t>::Write w = buff.write();
err = encode_variant(p_var, &w[0], len, p_full_objects); err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND_V(err != OK, ""); ERR_FAIL_COND_V_MSG(err != OK, "", "Error when trying to encode Variant.");
String ret = CryptoCore::b64_encode_str(&w[0], len); String ret = CryptoCore::b64_encode_str(&w[0], len);
ERR_FAIL_COND_V(ret == "", ret); ERR_FAIL_COND_V(ret == "", ret);
@ -2471,7 +2471,7 @@ Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects)
Variant v; Variant v;
Error err = decode_variant(v, &w[0], len, NULL, p_allow_objects); Error err = decode_variant(v, &w[0], len, NULL, p_allow_objects);
ERR_FAIL_COND_V(err != OK, Variant()); ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to decode Variant.");
return v; return v;
}; };
@ -2638,13 +2638,13 @@ void _Thread::_start_func(void *ud) {
} }
} }
ERR_FAIL_MSG("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() + "' to start thread " + t->get_id() + ": " + reason + ".");
} }
} }
Error _Thread::start(Object *p_instance, const StringName &p_method, const Variant &p_userdata, Priority p_priority) { Error _Thread::start(Object *p_instance, const StringName &p_method, const Variant &p_userdata, Priority p_priority) {
ERR_FAIL_COND_V(active, ERR_ALREADY_IN_USE); ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "Thread already started.");
ERR_FAIL_COND_V(!p_instance, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(!p_instance, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_method == StringName(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(p_method == StringName(), ERR_INVALID_PARAMETER);
ERR_FAIL_INDEX_V(p_priority, PRIORITY_MAX, ERR_INVALID_PARAMETER); ERR_FAIL_INDEX_V(p_priority, PRIORITY_MAX, ERR_INVALID_PARAMETER);
@ -2685,8 +2685,8 @@ bool _Thread::is_active() const {
} }
Variant _Thread::wait_to_finish() { Variant _Thread::wait_to_finish() {
ERR_FAIL_COND_V(!thread, Variant()); ERR_FAIL_COND_V_MSG(!thread, Variant(), "Thread must exist to wait for its completion.");
ERR_FAIL_COND_V(!active, Variant()); ERR_FAIL_COND_V_MSG(!active, Variant(), "Thread must be active to wait for its completion.");
Thread::wait_to_finish(thread); Thread::wait_to_finish(thread);
Variant r = ret; Variant r = ret;
active = false; active = false;

View File

@ -340,7 +340,7 @@ StringName ClassDB::get_parent_class(const StringName &p_class) {
OBJTYPE_RLOCK; OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class); ClassInfo *ti = classes.getptr(p_class);
ERR_FAIL_COND_V(!ti, StringName()); ERR_FAIL_COND_V_MSG(!ti, StringName(), "Cannot get class '" + String(p_class) + "'.");
return ti->inherits; return ti->inherits;
} }
@ -350,7 +350,7 @@ ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) {
ClassInfo *ti = classes.getptr(p_class); ClassInfo *ti = classes.getptr(p_class);
ERR_FAIL_COND_V(!ti, API_NONE); ERR_FAIL_COND_V_MSG(!ti, API_NONE, "Cannot get class '" + String(p_class) + "'.");
return ti->api; return ti->api;
} }
@ -375,7 +375,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
for (List<StringName>::Element *E = names.front(); E; E = E->next()) { for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
ClassInfo *t = classes.getptr(E->get()); ClassInfo *t = classes.getptr(E->get());
ERR_FAIL_COND_V(!t, 0); ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E->get()) + "'.");
if (t->api != p_api || !t->exposed) if (t->api != p_api || !t->exposed)
continue; continue;
hash = hash_djb2_one_64(t->name.hash(), hash); hash = hash_djb2_one_64(t->name.hash(), hash);
@ -528,8 +528,8 @@ Object *ClassDB::instance(const StringName &p_class) {
ti = classes.getptr(compat_classes[p_class]); ti = classes.getptr(compat_classes[p_class]);
} }
} }
ERR_FAIL_COND_V(!ti, NULL); ERR_FAIL_COND_V_MSG(!ti, NULL, "Cannot get class '" + String(p_class) + "'.");
ERR_FAIL_COND_V(ti->disabled, NULL); ERR_FAIL_COND_V_MSG(ti->disabled, NULL, "Class '" + String(p_class) + "' is disabled.");
ERR_FAIL_COND_V(!ti->creation_func, NULL); ERR_FAIL_COND_V(!ti->creation_func, NULL);
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
@ -545,7 +545,7 @@ bool ClassDB::can_instance(const StringName &p_class) {
OBJTYPE_RLOCK; OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class); ClassInfo *ti = classes.getptr(p_class);
ERR_FAIL_COND_V(!ti, false); ERR_FAIL_COND_V_MSG(!ti, false, "Cannot get class '" + String(p_class) + "'.");
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) { if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) {
return false; return false;
@ -560,7 +560,7 @@ void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherit
const StringName &name = p_class; const StringName &name = p_class;
ERR_FAIL_COND(classes.has(name)); ERR_FAIL_COND_MSG(classes.has(name), "Class '" + String(p_class) + "' already exists.");
classes[name] = ClassInfo(); classes[name] = ClassInfo();
ClassInfo &ti = classes[name]; ClassInfo &ti = classes[name];
@ -836,7 +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) {
ERR_FAIL_COND_MSG(check->signal_map.has(sname), "Type " + String(p_class) + " already has signal: " + String(sname) + "."); ERR_FAIL_COND_MSG(check->signal_map.has(sname), "Class '" + String(p_class) + "' already has signal '" + String(sname) + "'.");
check = check->inherits_ptr; check = check->inherits_ptr;
} }
#endif #endif
@ -922,10 +922,10 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
mb_set = get_method(p_class, p_setter); mb_set = get_method(p_class, p_setter);
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
ERR_FAIL_COND_MSG(!mb_set, "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 + "'.");
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 + "."); ERR_FAIL_COND_MSG(mb_set->get_argument_count() != exp_args, "Invalid function for setter '" + p_class + "::" + p_setter + " for property '" + p_pinfo.name + "'.");
#endif #endif
} }
@ -935,15 +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
ERR_FAIL_COND_MSG(!mb_get, "Invalid getter: " + p_class + "::" + p_getter + " for property: " + p_pinfo.name + "."); ERR_FAIL_COND_MSG(!mb_get, "Invalid getter '" + p_class + "::" + p_getter + "' for property '" + p_pinfo.name + "'.");
int exp_args = 0 + (p_index >= 0 ? 1 : 0); int exp_args = 0 + (p_index >= 0 ? 1 : 0);
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_FAIL_COND_MSG(mb_get->get_argument_count() != exp_args, "Invalid function for getter '" + p_class + "::" + p_getter + "' for property: '" + p_pinfo.name + "'.");
#endif #endif
} }
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
ERR_FAIL_COND_MSG(type->property_setget.has(p_pinfo.name), "Object " + p_class + " already has property: " + p_pinfo.name + "."); ERR_FAIL_COND_MSG(type->property_setget.has(p_pinfo.name), "Object '" + p_class + "' already has property '" + p_pinfo.name + "'.");
#endif #endif
OBJTYPE_WLOCK OBJTYPE_WLOCK
@ -1228,20 +1228,20 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
ClassInfo *type = classes.getptr(instance_type); ClassInfo *type = classes.getptr(instance_type);
if (!type) { if (!type) {
memdelete(p_bind); memdelete(p_bind);
ERR_FAIL_V_MSG(NULL, "Couldn't bind method '" + mdname + "' for instance: " + instance_type + "."); 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_FAIL_V_MSG(NULL, "Method already bound: " + instance_type + "::" + mdname + "."); ERR_FAIL_V_MSG(NULL, "Method already bound '" + instance_type + "::" + mdname + "'.");
} }
#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_FAIL_V_MSG(NULL, "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 + "'.");
} }
p_bind->set_argument_names(method_name.args); p_bind->set_argument_names(method_name.args);
@ -1265,7 +1265,7 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
} }
void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual) { void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual) {
ERR_FAIL_COND(!classes.has(p_class)); ERR_FAIL_COND_MSG(!classes.has(p_class), "Request for nonexistent class '" + p_class + "'.");
OBJTYPE_WLOCK; OBJTYPE_WLOCK;
@ -1280,7 +1280,7 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_
void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance) { void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance) {
ERR_FAIL_COND(!classes.has(p_class)); ERR_FAIL_COND_MSG(!classes.has(p_class), "Request for nonexistent class '" + p_class + "'.");
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
@ -1304,7 +1304,7 @@ void ClassDB::set_class_enabled(StringName p_class, bool p_enable) {
OBJTYPE_WLOCK; OBJTYPE_WLOCK;
ERR_FAIL_COND(!classes.has(p_class)); ERR_FAIL_COND_MSG(!classes.has(p_class), "Request for nonexistent class '" + p_class + "'.");
classes[p_class].disabled = !p_enable; classes[p_class].disabled = !p_enable;
} }
@ -1319,7 +1319,7 @@ bool ClassDB::is_class_enabled(StringName p_class) {
} }
} }
ERR_FAIL_COND_V(!ti, false); ERR_FAIL_COND_V_MSG(!ti, false, "Cannot get class '" + String(p_class) + "'.");
return !ti->disabled; return !ti->disabled;
} }
@ -1328,7 +1328,7 @@ bool ClassDB::is_class_exposed(StringName p_class) {
OBJTYPE_RLOCK; OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class); ClassInfo *ti = classes.getptr(p_class);
ERR_FAIL_COND_V(!ti, false); ERR_FAIL_COND_V_MSG(!ti, false, "Cannot get class '" + String(p_class) + "'.");
return ti->exposed; return ti->exposed;
} }

View File

@ -149,7 +149,7 @@ Error ResourceFormatSaverCrypto::save(const String &p_path, const RES &p_resourc
} else { } else {
ERR_FAIL_V(ERR_INVALID_PARAMETER); ERR_FAIL_V(ERR_INVALID_PARAMETER);
} }
ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save Crypto resource to file '" + p_path + "'.");
return OK; return OK;
} }

View File

@ -38,7 +38,7 @@
void Engine::set_iterations_per_second(int p_ips) { void Engine::set_iterations_per_second(int p_ips) {
ERR_FAIL_COND(p_ips <= 0); ERR_FAIL_COND_MSG(p_ips <= 0, "Engine iterations per second must be greater than 0.");
ips = p_ips; ips = p_ips;
} }
int Engine::get_iterations_per_second() const { int Engine::get_iterations_per_second() const {

View File

@ -112,7 +112,7 @@ private:
void erase_hash_table() { void erase_hash_table() {
ERR_FAIL_COND(elements); ERR_FAIL_COND_MSG(elements, "Cannot erase hash table if there are still elements inside.");
memdelete_arr(hash_table); memdelete_arr(hash_table);
hash_table = 0; hash_table = 0;

View File

@ -885,10 +885,10 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */; bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */;
ERR_FAIL_COND(p_width <= 0); ERR_FAIL_COND_MSG(p_width <= 0, "Image width cannot be greater than 0.");
ERR_FAIL_COND(p_height <= 0); ERR_FAIL_COND_MSG(p_height <= 0, "Image height cannot be greater than 0.");
ERR_FAIL_COND(p_width > MAX_WIDTH); ERR_FAIL_COND_MSG(p_width > MAX_WIDTH, "Image width cannot be greater than " + itos(MAX_WIDTH) + ".");
ERR_FAIL_COND(p_height > MAX_HEIGHT); ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT, "Image height cannot be greater than " + itos(MAX_HEIGHT) + ".");
if (p_width == width && p_height == height) if (p_width == width && p_height == height)
return; return;
@ -1096,12 +1096,12 @@ void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot crop in compressed or custom image formats."); ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot crop in compressed or custom image formats.");
ERR_FAIL_COND(p_x < 0); ERR_FAIL_COND_MSG(p_x < 0, "Start x position cannot be smaller than 0.");
ERR_FAIL_COND(p_y < 0); ERR_FAIL_COND_MSG(p_y < 0, "Start y position cannot be smaller than 0.");
ERR_FAIL_COND(p_width <= 0); ERR_FAIL_COND_MSG(p_width <= 0, "Width of image must be greater than 0.");
ERR_FAIL_COND(p_height <= 0); ERR_FAIL_COND_MSG(p_height <= 0, "Height of image must be greater than 0.");
ERR_FAIL_COND(p_x + p_width > MAX_WIDTH); ERR_FAIL_COND_MSG(p_x + p_width > MAX_WIDTH, "End x position cannot be greater than " + itos(MAX_WIDTH) + ".");
ERR_FAIL_COND(p_y + p_height > MAX_HEIGHT); ERR_FAIL_COND_MSG(p_y + p_height > MAX_HEIGHT, "End y position cannot be greater than " + itos(MAX_HEIGHT) + ".");
/* to save memory, cropping should be done in-place, however, since this function /* to save memory, cropping should be done in-place, however, since this function
will most likely either not be used much, or in critical areas, for now it won't, because will most likely either not be used much, or in critical areas, for now it won't, because
@ -2055,7 +2055,7 @@ Ref<Image> Image::get_rect(const Rect2 &p_area) const {
void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest) { void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest) {
ERR_FAIL_COND(p_src.is_null()); ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
int dsize = data.size(); int dsize = data.size();
int srcdsize = p_src->data.size(); int srcdsize = p_src->data.size();
ERR_FAIL_COND(dsize == 0); ERR_FAIL_COND(dsize == 0);
@ -2105,16 +2105,16 @@ void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Po
void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) { void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) {
ERR_FAIL_COND(p_src.is_null()); ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
ERR_FAIL_COND(p_mask.is_null()); ERR_FAIL_COND_MSG(p_mask.is_null(), "It's not a reference to a valid Image object.");
int dsize = data.size(); int dsize = data.size();
int srcdsize = p_src->data.size(); int srcdsize = p_src->data.size();
int maskdsize = p_mask->data.size(); int maskdsize = p_mask->data.size();
ERR_FAIL_COND(dsize == 0); ERR_FAIL_COND(dsize == 0);
ERR_FAIL_COND(srcdsize == 0); ERR_FAIL_COND(srcdsize == 0);
ERR_FAIL_COND(maskdsize == 0); ERR_FAIL_COND(maskdsize == 0);
ERR_FAIL_COND(p_src->width != p_mask->width); ERR_FAIL_COND_MSG(p_src->width != p_mask->width, "Source image width is different from mask width.");
ERR_FAIL_COND(p_src->height != p_mask->height); ERR_FAIL_COND_MSG(p_src->height != p_mask->height, "Source image height is different from mask height.");
ERR_FAIL_COND(format != p_src->format); ERR_FAIL_COND(format != p_src->format);
Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect); Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect);
@ -2168,7 +2168,7 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co
void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest) { void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest) {
ERR_FAIL_COND(p_src.is_null()); ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
int dsize = data.size(); int dsize = data.size();
int srcdsize = p_src->data.size(); int srcdsize = p_src->data.size();
ERR_FAIL_COND(dsize == 0); ERR_FAIL_COND(dsize == 0);
@ -2218,16 +2218,16 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) { void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) {
ERR_FAIL_COND(p_src.is_null()); ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
ERR_FAIL_COND(p_mask.is_null()); ERR_FAIL_COND_MSG(p_mask.is_null(), "It's not a reference to a valid Image object.");
int dsize = data.size(); int dsize = data.size();
int srcdsize = p_src->data.size(); int srcdsize = p_src->data.size();
int maskdsize = p_mask->data.size(); int maskdsize = p_mask->data.size();
ERR_FAIL_COND(dsize == 0); ERR_FAIL_COND(dsize == 0);
ERR_FAIL_COND(srcdsize == 0); ERR_FAIL_COND(srcdsize == 0);
ERR_FAIL_COND(maskdsize == 0); ERR_FAIL_COND(maskdsize == 0);
ERR_FAIL_COND(p_src->width != p_mask->width); ERR_FAIL_COND_MSG(p_src->width != p_mask->width, "Source image width is different from mask width.");
ERR_FAIL_COND(p_src->height != p_mask->height); ERR_FAIL_COND_MSG(p_src->height != p_mask->height, "Source image height is different from mask height.");
ERR_FAIL_COND(format != p_src->format); ERR_FAIL_COND(format != p_src->format);
Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect); Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect);

View File

@ -356,7 +356,7 @@ public:
void set_pixel(int p_x, int p_y, const Color &p_color); void set_pixel(int p_x, int p_y, const Color &p_color);
void copy_internals_from(const Ref<Image> &p_image) { void copy_internals_from(const Ref<Image> &p_image) {
ERR_FAIL_COND(p_image.is_null()); ERR_FAIL_COND_MSG(p_image.is_null(), "It's not a reference to a valid Image object.");
format = p_image->format; format = p_image->format;
width = p_image->width; width = p_image->width;
height = p_image->height; height = p_image->height;

View File

@ -56,7 +56,7 @@ void InputMap::_bind_methods() {
void InputMap::add_action(const StringName &p_action, float p_deadzone) { void InputMap::add_action(const StringName &p_action, float p_deadzone) {
ERR_FAIL_COND(input_map.has(p_action)); ERR_FAIL_COND_MSG(input_map.has(p_action), "InputMap already has action '" + String(p_action) + "'.");
input_map[p_action] = Action(); input_map[p_action] = Action();
static int last_id = 1; static int last_id = 1;
input_map[p_action].id = last_id; input_map[p_action].id = last_id;
@ -66,7 +66,7 @@ void InputMap::add_action(const StringName &p_action, float p_deadzone) {
void InputMap::erase_action(const StringName &p_action) { void InputMap::erase_action(const StringName &p_action) {
ERR_FAIL_COND(!input_map.has(p_action)); ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
input_map.erase(p_action); input_map.erase(p_action);
} }
@ -126,15 +126,15 @@ bool InputMap::has_action(const StringName &p_action) const {
void InputMap::action_set_deadzone(const StringName &p_action, float p_deadzone) { void InputMap::action_set_deadzone(const StringName &p_action, float p_deadzone) {
ERR_FAIL_COND(!input_map.has(p_action)); ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
input_map[p_action].deadzone = p_deadzone; input_map[p_action].deadzone = p_deadzone;
} }
void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event) { void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null()); ERR_FAIL_COND_MSG(p_event.is_null(), "It's not a reference to a valid InputEvent object.");
ERR_FAIL_COND(!input_map.has(p_action)); ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
if (_find_event(input_map[p_action], p_event)) if (_find_event(input_map[p_action], p_event))
return; //already gots return; //already gots
@ -143,13 +143,13 @@ void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent
bool InputMap::action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event) { bool InputMap::action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND_V(!input_map.has(p_action), false); ERR_FAIL_COND_V_MSG(!input_map.has(p_action), false, "Request for nonexistent InputMap action '" + String(p_action) + "'.");
return (_find_event(input_map[p_action], p_event) != NULL); return (_find_event(input_map[p_action], p_event) != NULL);
} }
void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event) { void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(!input_map.has(p_action)); ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
List<Ref<InputEvent> >::Element *E = _find_event(input_map[p_action], p_event); List<Ref<InputEvent> >::Element *E = _find_event(input_map[p_action], p_event);
if (E) if (E)
@ -158,7 +158,7 @@ void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEve
void InputMap::action_erase_events(const StringName &p_action) { void InputMap::action_erase_events(const StringName &p_action) {
ERR_FAIL_COND(!input_map.has(p_action)); ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
input_map[p_action].inputs.clear(); input_map[p_action].inputs.clear();
} }
@ -192,7 +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);
ERR_FAIL_COND_V_MSG(!E, false, "Request for nonexistent InputMap action: " + String(p_action) + "."); ERR_FAIL_COND_V_MSG(!E, false, "Request for nonexistent InputMap action '" + String(p_action) + "'.");
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()) {
@ -333,6 +333,6 @@ void InputMap::load_default() {
InputMap::InputMap() { InputMap::InputMap() {
ERR_FAIL_COND(singleton); ERR_FAIL_COND_MSG(singleton, "Singleton in InputMap already exist.");
singleton = this; singleton = this;
} }

View File

@ -111,7 +111,7 @@ void ConfigFile::get_sections(List<String> *r_sections) const {
} }
void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const { void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const {
ERR_FAIL_COND(!values.has(p_section)); ERR_FAIL_COND_MSG(!values.has(p_section), "Cannont get keys from nonexistent section '" + p_section + "'.");
for (OrderedHashMap<String, Variant>::ConstElement E = values[p_section].front(); E; E = E.next()) { for (OrderedHashMap<String, Variant>::ConstElement E = values[p_section].front(); E; E = E.next()) {
r_keys->push_back(E.key()); r_keys->push_back(E.key());

View File

@ -195,7 +195,7 @@ bool FileAccessCompressed::is_open() const {
void FileAccessCompressed::seek(size_t p_position) { void FileAccessCompressed::seek(size_t p_position) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
if (writing) { if (writing) {
ERR_FAIL_COND(p_position > write_max); ERR_FAIL_COND(p_position > write_max);
@ -227,7 +227,7 @@ void FileAccessCompressed::seek(size_t p_position) {
void FileAccessCompressed::seek_end(int64_t p_position) { void FileAccessCompressed::seek_end(int64_t p_position) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
if (writing) { if (writing) {
seek(write_max + p_position); seek(write_max + p_position);
@ -238,7 +238,7 @@ void FileAccessCompressed::seek_end(int64_t p_position) {
} }
size_t FileAccessCompressed::get_position() const { size_t FileAccessCompressed::get_position() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
if (writing) { if (writing) {
return write_pos; return write_pos;
@ -249,7 +249,7 @@ size_t FileAccessCompressed::get_position() const {
} }
size_t FileAccessCompressed::get_len() const { size_t FileAccessCompressed::get_len() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
if (writing) { if (writing) {
return write_max; return write_max;
@ -260,7 +260,7 @@ size_t FileAccessCompressed::get_len() const {
bool FileAccessCompressed::eof_reached() const { bool FileAccessCompressed::eof_reached() const {
ERR_FAIL_COND_V(!f, false); ERR_FAIL_COND_V_MSG(!f, false, "File must be opened before use.");
if (writing) { if (writing) {
return false; return false;
} else { } else {
@ -270,8 +270,8 @@ bool FileAccessCompressed::eof_reached() const {
uint8_t FileAccessCompressed::get_8() const { uint8_t FileAccessCompressed::get_8() const {
ERR_FAIL_COND_V(writing, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
if (at_end) { if (at_end) {
read_eof = true; read_eof = true;
@ -301,8 +301,8 @@ uint8_t FileAccessCompressed::get_8() const {
} }
int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(writing, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
if (at_end) { if (at_end) {
read_eof = true; read_eof = true;
@ -342,16 +342,16 @@ Error FileAccessCompressed::get_error() const {
} }
void FileAccessCompressed::flush() { void FileAccessCompressed::flush() {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND(!writing); ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
// compressed files keep data in memory till close() // compressed files keep data in memory till close()
} }
void FileAccessCompressed::store_8(uint8_t p_dest) { void FileAccessCompressed::store_8(uint8_t p_dest) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND(!writing); ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
WRITE_FIT(1); WRITE_FIT(1);
write_ptr[write_pos++] = p_dest; write_ptr[write_pos++] = p_dest;

View File

@ -41,7 +41,7 @@
Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode) { Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode) {
ERR_FAIL_COND_V(file != NULL, ERR_ALREADY_IN_USE); ERR_FAIL_COND_V_MSG(file != NULL, ERR_ALREADY_IN_USE, "Can't open file while another file from path '" + file->get_path_absolute() + "' is open.");
ERR_FAIL_COND_V(p_key.size() != 32, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(p_key.size() != 32, ERR_INVALID_PARAMETER);
pos = 0; pos = 0;
@ -205,7 +205,7 @@ bool FileAccessEncrypted::eof_reached() const {
uint8_t FileAccessEncrypted::get_8() const { uint8_t FileAccessEncrypted::get_8() const {
ERR_FAIL_COND_V(writing, 0); ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
if (pos >= data.size()) { if (pos >= data.size()) {
eofed = true; eofed = true;
return 0; return 0;
@ -217,7 +217,7 @@ uint8_t FileAccessEncrypted::get_8() const {
} }
int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(writing, 0); ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
int to_copy = MIN(p_length, data.size() - pos); int to_copy = MIN(p_length, data.size() - pos);
for (int i = 0; i < to_copy; i++) { for (int i = 0; i < to_copy; i++) {
@ -239,7 +239,7 @@ Error FileAccessEncrypted::get_error() const {
void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) { void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) {
ERR_FAIL_COND(!writing); ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
if (pos < data.size()) { if (pos < data.size()) {
@ -259,14 +259,14 @@ void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) {
} }
void FileAccessEncrypted::flush() { void FileAccessEncrypted::flush() {
ERR_FAIL_COND(!writing); ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
// encrypted files keep data in memory till close() // encrypted files keep data in memory till close()
} }
void FileAccessEncrypted::store_8(uint8_t p_dest) { void FileAccessEncrypted::store_8(uint8_t p_dest) {
ERR_FAIL_COND(!writing); ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
if (pos < data.size()) { if (pos < data.size()) {
data.write[pos] = p_dest; data.write[pos] = p_dest;

View File

@ -90,7 +90,7 @@ Error FileAccessMemory::_open(const String &p_path, int p_mode_flags) {
//name = DirAccess::normalize_path(name); //name = DirAccess::normalize_path(name);
Map<String, Vector<uint8_t> >::Element *E = files->find(name); Map<String, Vector<uint8_t> >::Element *E = files->find(name);
ERR_FAIL_COND_V(!E, ERR_FILE_NOT_FOUND); ERR_FAIL_COND_V_MSG(!E, ERR_FILE_NOT_FOUND, "Can't find file '" + p_path + "'.");
data = E->get().ptrw(); data = E->get().ptrw();
length = E->get().size(); length = E->get().size();

View File

@ -195,7 +195,7 @@ Error FileAccessNetworkClient::connect(const String &p_host, int p_port, const S
DEBUG_PRINT("IP: " + String(ip) + " port " + itos(p_port)); DEBUG_PRINT("IP: " + String(ip) + " port " + itos(p_port));
Error err = client->connect_to_host(ip, p_port); Error err = client->connect_to_host(ip, p_port);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot connect to host with IP: " + String(ip) + " and port: " + itos(p_port));
while (client->get_status() == StreamPeerTCP::STATUS_CONNECTING) { while (client->get_status() == StreamPeerTCP::STATUS_CONNECTING) {
//DEBUG_PRINT("trying to connect...."); //DEBUG_PRINT("trying to connect....");
OS::get_singleton()->delay_usec(1000); OS::get_singleton()->delay_usec(1000);
@ -339,7 +339,7 @@ bool FileAccessNetwork::is_open() const {
void FileAccessNetwork::seek(size_t p_position) { void FileAccessNetwork::seek(size_t p_position) {
ERR_FAIL_COND(!opened); ERR_FAIL_COND_MSG(!opened, "File must be opened before use.");
eof_flag = p_position > total_size; eof_flag = p_position > total_size;
if (p_position >= total_size) { if (p_position >= total_size) {
@ -355,18 +355,18 @@ void FileAccessNetwork::seek_end(int64_t p_position) {
} }
size_t FileAccessNetwork::get_position() const { size_t FileAccessNetwork::get_position() const {
ERR_FAIL_COND_V(!opened, 0); ERR_FAIL_COND_V_MSG(!opened, 0, "File must be opened before use.");
return pos; return pos;
} }
size_t FileAccessNetwork::get_len() const { size_t FileAccessNetwork::get_len() const {
ERR_FAIL_COND_V(!opened, 0); ERR_FAIL_COND_V_MSG(!opened, 0, "File must be opened before use.");
return total_size; return total_size;
} }
bool FileAccessNetwork::eof_reached() const { bool FileAccessNetwork::eof_reached() const {
ERR_FAIL_COND_V(!opened, false); ERR_FAIL_COND_V_MSG(!opened, false, "File must be opened before use.");
return eof_flag; return eof_flag;
} }

View File

@ -321,7 +321,7 @@ FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFil
pf(p_file), pf(p_file),
f(FileAccess::open(pf.pack, FileAccess::READ)) { f(FileAccess::open(pf.pack, FileAccess::READ)) {
ERR_FAIL_COND_MSG(!f, "Can't open pack-referenced file: " + String(pf.pack) + "."); ERR_FAIL_COND_MSG(!f, "Can't open pack-referenced file '" + String(pf.pack) + "'.");
f->seek(pf.offset); f->seek(pf.offset);
pos = 0; pos = 0;

View File

@ -117,7 +117,7 @@ static void godot_free(voidpf opaque, voidpf address) {
void ZipArchive::close_handle(unzFile p_file) const { void ZipArchive::close_handle(unzFile p_file) const {
ERR_FAIL_COND(!p_file); ERR_FAIL_COND_MSG(!p_file, "Cannot close a file if none is open.");
FileAccess *f = (FileAccess *)unzGetOpaque(p_file); FileAccess *f = (FileAccess *)unzGetOpaque(p_file);
unzCloseCurrentFile(p_file); unzCloseCurrentFile(p_file);
unzClose(p_file); unzClose(p_file);
@ -126,11 +126,11 @@ void ZipArchive::close_handle(unzFile p_file) const {
unzFile ZipArchive::get_file_handle(String p_file) const { unzFile ZipArchive::get_file_handle(String p_file) const {
ERR_FAIL_COND_V(!file_exists(p_file), NULL); ERR_FAIL_COND_V_MSG(!file_exists(p_file), NULL, "File '" + p_file + " doesn't exist.");
File file = files[p_file]; File file = files[p_file];
FileAccess *f = FileAccess::open(packages[file.package].filename, FileAccess::READ); FileAccess *f = FileAccess::open(packages[file.package].filename, FileAccess::READ);
ERR_FAIL_COND_V(!f, NULL); ERR_FAIL_COND_V_MSG(!f, NULL, "Cannot open file '" + packages[file.package].filename + "'.");
zlib_filefunc_def io; zlib_filefunc_def io;
zeromem(&io, sizeof(io)); zeromem(&io, sizeof(io));

View File

@ -46,14 +46,14 @@ bool ImageFormatLoader::recognize(const String &p_extension) const {
} }
Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom, bool p_force_linear, float p_scale) { Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom, bool p_force_linear, float p_scale) {
ERR_FAIL_COND_V(p_image.is_null(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(p_image.is_null(), ERR_INVALID_PARAMETER, "It's not a reference to a valid Image object.");
FileAccess *f = p_custom; FileAccess *f = p_custom;
if (!f) { if (!f) {
Error err; Error err;
f = FileAccess::open(p_file, FileAccess::READ, &err); f = FileAccess::open(p_file, FileAccess::READ, &err);
if (!f) { if (!f) {
ERR_PRINTS("Error opening file: " + p_file); ERR_PRINTS("Error opening file '" + p_file + "'.");
return err; return err;
} }
} }

View File

@ -305,7 +305,7 @@ IP *(*IP::_create)() = NULL;
IP *IP::create() { IP *IP::create() {
ERR_FAIL_COND_V(singleton, NULL); ERR_FAIL_COND_V_MSG(singleton, NULL, "IP singleton already exist.");
ERR_FAIL_COND_V(!_create, NULL); ERR_FAIL_COND_V(!_create, NULL);
return _create(); return _create();
} }

View File

@ -181,7 +181,7 @@ bool IP_Address::is_ipv4() const {
} }
const uint8_t *IP_Address::get_ipv4() const { const uint8_t *IP_Address::get_ipv4() const {
ERR_FAIL_COND_V(!is_ipv4(), &(field8[12])); // Not the correct IPv4 (it's an IPv6), but we don't want to return a null pointer risking an engine crash. ERR_FAIL_COND_V_MSG(!is_ipv4(), &(field8[12]), "IPv4 requested, but current IP is IPv6."); // Not the correct IPv4 (it's an IPv6), but we don't want to return a null pointer risking an engine crash.
return &(field8[12]); return &(field8[12]);
} }

View File

@ -478,7 +478,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
int used; int used;
Error err = decode_variant(key, buf, len, &used, p_allow_objects); Error err = decode_variant(key, buf, len, &used, p_allow_objects);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Error when trying to decode Variant.");
buf += used; buf += used;
len -= used; len -= used;
@ -487,7 +487,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} }
err = decode_variant(value, buf, len, &used, p_allow_objects); err = decode_variant(value, buf, len, &used, p_allow_objects);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Error when trying to decode Variant.");
buf += used; buf += used;
len -= used; len -= used;
@ -522,7 +522,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
int used = 0; int used = 0;
Variant v; Variant v;
Error err = decode_variant(v, buf, len, &used, p_allow_objects); Error err = decode_variant(v, buf, len, &used, p_allow_objects);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Error when trying to decode Variant.");
buf += used; buf += used;
len -= used; len -= used;
varr.push_back(v); varr.push_back(v);

View File

@ -917,8 +917,7 @@ int MultiplayerAPI::_get_bandwidth_usage(const Vector<BandwidthFrame> &p_buffer,
i = (i + p_buffer.size() - 1) % p_buffer.size(); i = (i + p_buffer.size() - 1) % p_buffer.size();
} }
ERR_EXPLAIN("Reached the end of the bandwidth profiler buffer, values might be inaccurate."); ERR_FAIL_COND_V_MSG(i == p_pointer, total_bandwidth, "Reached the end of the bandwidth profiler buffer, values might be inaccurate.");
ERR_FAIL_COND_V(i == p_pointer, total_bandwidth);
return total_bandwidth; return total_bandwidth;
} }

View File

@ -101,9 +101,9 @@ Error PacketPeer::put_var(const Variant &p_packet, bool p_full_objects) {
return OK; return OK;
uint8_t *buf = (uint8_t *)alloca(len); uint8_t *buf = (uint8_t *)alloca(len);
ERR_FAIL_COND_V(!buf, ERR_OUT_OF_MEMORY); ERR_FAIL_COND_V_MSG(!buf, ERR_OUT_OF_MEMORY, "Out of memory.");
err = encode_variant(p_packet, buf, len, p_full_objects || allow_object_decoding); err = encode_variant(p_packet, buf, len, p_full_objects || allow_object_decoding);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Error when trying to encode Variant.");
return put_packet(buf, len); return put_packet(buf, len);
} }
@ -150,7 +150,7 @@ void PacketPeer::_bind_methods() {
void PacketPeerStream::_set_stream_peer(REF p_peer) { void PacketPeerStream::_set_stream_peer(REF p_peer) {
ERR_FAIL_COND(p_peer.is_null()); ERR_FAIL_COND_MSG(p_peer.is_null(), "It's not a reference to a valid Resource object.");
set_stream_peer(p_peer); set_stream_peer(p_peer);
} }

View File

@ -107,7 +107,7 @@ Error PCKPacker::add_file(const String &p_file, const String &p_src) {
Error PCKPacker::flush(bool p_verbose) { Error PCKPacker::flush(bool p_verbose) {
ERR_FAIL_COND_V(!file, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(!file, ERR_INVALID_PARAMETER, "File must be opened before use.");
// write the index // write the index

View File

@ -378,10 +378,10 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
for (uint32_t i = 0; i < len; i++) { for (uint32_t i = 0; i < len; i++) {
Variant key; Variant key;
Error err = parse_variant(key); Error err = parse_variant(key);
ERR_FAIL_COND_V(err, ERR_FILE_CORRUPT); ERR_FAIL_COND_V_MSG(err, ERR_FILE_CORRUPT, "Error when trying to parse Variant.");
Variant value; Variant value;
err = parse_variant(value); err = parse_variant(value);
ERR_FAIL_COND_V(err, ERR_FILE_CORRUPT); ERR_FAIL_COND_V_MSG(err, ERR_FILE_CORRUPT, "Error when trying to parse Variant.");
d[key] = value; d[key] = value;
} }
r_v = d; r_v = d;
@ -395,7 +395,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
for (uint32_t i = 0; i < len; i++) { for (uint32_t i = 0; i < len; i++) {
Variant val; Variant val;
Error err = parse_variant(val); Error err = parse_variant(val);
ERR_FAIL_COND_V(err, ERR_FILE_CORRUPT); ERR_FAIL_COND_V_MSG(err, ERR_FILE_CORRUPT, "Error when trying to parse Variant.");
a[i] = val; a[i] = val;
} }
r_v = a; r_v = a;
@ -983,7 +983,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(cons
Error err; Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
ERR_FAIL_COND_V(err != OK, Ref<ResourceInteractiveLoader>()); ERR_FAIL_COND_V_MSG(err != OK, Ref<ResourceInteractiveLoader>(), "Cannot open file '" + p_path + "'.");
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary); Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
String path = p_original_path != "" ? p_original_path : p_path; String path = p_original_path != "" ? p_original_path : p_path;
@ -1032,7 +1032,7 @@ bool ResourceFormatLoaderBinary::handles_type(const String &p_type) const {
void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) { void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
FileAccess *f = FileAccess::open(p_path, FileAccess::READ); FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "Cannot open file '" + p_path + "'.");
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary); Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path); ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
@ -1046,7 +1046,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
//Error error=OK; //Error error=OK;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ); FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file '" + p_path + "'.");
FileAccess *fw = NULL; //=FileAccess::open(p_path+".depren"); FileAccess *fw = NULL; //=FileAccess::open(p_path+".depren");
@ -1066,7 +1066,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
if (err) { if (err) {
memdelete(fac); memdelete(fac);
memdelete(facw); memdelete(facw);
ERR_FAIL_COND_V(err, ERR_FILE_CORRUPT); ERR_FAIL_COND_V_MSG(err, ERR_FILE_CORRUPT, "Cannot create file '" + p_path + ".depren'.");
} }
fw = facw; fw = facw;
@ -1076,13 +1076,13 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
//error=ERR_FILE_UNRECOGNIZED; //error=ERR_FILE_UNRECOGNIZED;
memdelete(f); memdelete(f);
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unrecognized binary resource file: " + local_path + "."); ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unrecognized binary resource file '" + local_path + "'.");
} else { } else {
fw = FileAccess::open(p_path + ".depren", FileAccess::WRITE); fw = FileAccess::open(p_path + ".depren", FileAccess::WRITE);
if (!fw) { if (!fw) {
memdelete(f); memdelete(f);
} }
ERR_FAIL_COND_V(!fw, ERR_CANT_CREATE); ERR_FAIL_COND_V_MSG(!fw, ERR_CANT_CREATE, "Cannot create file '" + p_path + ".depren'.");
uint8_t magic[4] = { 'R', 'S', 'R', 'C' }; uint8_t magic[4] = { 'R', 'S', 'R', 'C' };
fw->store_buffer(magic, 4); fw->store_buffer(magic, 4);
@ -1113,12 +1113,12 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
memdelete(da); memdelete(da);
//use the old approach //use the old approach
WARN_PRINTS("This file is old, so it can't refactor dependencies, opening and resaving: " + p_path + "."); 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);
ERR_FAIL_COND_V(err != OK, ERR_FILE_CANT_OPEN); ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_CANT_OPEN, "Cannot open file '" + p_path + "'.");
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary); Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path); ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
@ -1751,7 +1751,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
f = FileAccess::open(p_path, FileAccess::WRITE, &err); f = FileAccess::open(p_path, FileAccess::WRITE, &err);
} }
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create file '" + p_path + "'.");
relative_paths = p_flags & ResourceSaver::FLAG_RELATIVE_PATHS; relative_paths = p_flags & ResourceSaver::FLAG_RELATIVE_PATHS;
skip_editor = p_flags & ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES; skip_editor = p_flags & ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;

View File

@ -205,7 +205,7 @@ RES ResourceFormatLoader::load(const String &p_path, const String &p_original_pa
if (r_error) if (r_error)
*r_error = err; *r_error = err;
ERR_FAIL_COND_V(err != OK, RES()); ERR_FAIL_COND_V_MSG(err != OK, RES(), "Failed to load resource '" + p_path + "'.");
} }
} }

View File

@ -158,7 +158,7 @@ void ResourceSaver::get_recognized_extensions(const RES &p_resource, List<String
void ResourceSaver::add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front) { void ResourceSaver::add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front) {
ERR_FAIL_COND(p_format_saver.is_null()); ERR_FAIL_COND_MSG(p_format_saver.is_null(), "It's not a reference to a valid ResourceFormatSaver object.");
ERR_FAIL_COND(saver_count >= MAX_SAVERS); ERR_FAIL_COND(saver_count >= MAX_SAVERS);
if (p_at_front) { if (p_at_front) {
@ -174,7 +174,7 @@ void ResourceSaver::add_resource_format_saver(Ref<ResourceFormatSaver> p_format_
void ResourceSaver::remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver) { void ResourceSaver::remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver) {
ERR_FAIL_COND(p_format_saver.is_null()); ERR_FAIL_COND_MSG(p_format_saver.is_null(), "It's not a reference to a valid ResourceFormatSaver object.");
// Find saver // Find saver
int i = 0; int i = 0;

View File

@ -370,7 +370,7 @@ Variant StreamPeer::get_var(bool p_allow_objects) {
Variant ret; Variant ret;
err = decode_variant(ret, var.ptr(), len, NULL, p_allow_objects); err = decode_variant(ret, var.ptr(), len, NULL, p_allow_objects);
ERR_FAIL_COND_V(err != OK, Variant()); ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to decode Variant.");
return ret; return ret;
} }

View File

@ -182,7 +182,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String &p_original_pat
*r_error = ERR_CANT_OPEN; *r_error = ERR_CANT_OPEN;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ); FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V(!f, RES()); ERR_FAIL_COND_V_MSG(!f, RES(), "Cannot open file '" + p_path + "'.");
return load_translation(f, r_error); return load_translation(f, r_error);
} }

View File

@ -484,7 +484,7 @@ Error XMLParser::open(const String &p_path) {
Error err; Error err;
FileAccess *file = FileAccess::open(p_path, FileAccess::READ, &err); FileAccess *file = FileAccess::open(p_path, FileAccess::READ, &err);
ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot open file '" + p_path + "'.");
length = file->get_len(); length = file->get_len();
ERR_FAIL_COND_V(length < 1, ERR_FILE_CORRUPT); ERR_FAIL_COND_V(length < 1, ERR_FILE_CORRUPT);

View File

@ -807,7 +807,7 @@ void Basis::set_quat(const Quat &p_quat) {
void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) { void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) {
// Rotation matrix from axis and angle, see https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_angle // Rotation matrix from axis and angle, see https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_angle
#ifdef MATH_CHECKS #ifdef MATH_CHECKS
ERR_FAIL_COND(!p_axis.is_normalized()); ERR_FAIL_COND_MSG(!p_axis.is_normalized(), "Axis must be normalized.");
#endif #endif
Vector3 axis_sq(p_axis.x * p_axis.x, p_axis.y * p_axis.y, p_axis.z * p_axis.z); Vector3 axis_sq(p_axis.x * p_axis.x, p_axis.y * p_axis.y, p_axis.z * p_axis.z);
real_t cosine = Math::cos(p_phi); real_t cosine = Math::cos(p_phi);

View File

@ -241,10 +241,7 @@ PoolVector<PoolVector<Face3> > Geometry::separate_objects(PoolVector<Face3> p_ar
bool error = _connect_faces(_fcptr, len, -1); bool error = _connect_faces(_fcptr, len, -1);
if (error) { ERR_FAIL_COND_V_MSG(error, PoolVector<PoolVector<Face3> >(), "Invalid geometry.");
ERR_FAIL_COND_V(error, PoolVector<PoolVector<Face3> >()); // Invalid geometry.
}
// Group connected faces in separate objects. // Group connected faces in separate objects.

View File

@ -340,7 +340,7 @@ bool MessageQueue::is_flushing() const {
MessageQueue::MessageQueue() { MessageQueue::MessageQueue() {
ERR_FAIL_COND(singleton != NULL); ERR_FAIL_COND_MSG(singleton != NULL, "MessageQueue singleton already exist.");
singleton = this; singleton = this;
flushing = false; flushing = false;

View File

@ -375,7 +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_FAIL_MSG("Invalid NodePath: " + p_path + "."); ERR_FAIL_MSG("Invalid NodePath '" + p_path + "'.");
} }
subpath.push_back(str); subpath.push_back(str);

View File

@ -1100,9 +1100,9 @@ void Object::get_meta_list(List<String> *p_list) const {
void Object::add_user_signal(const MethodInfo &p_signal) { void Object::add_user_signal(const MethodInfo &p_signal) {
ERR_FAIL_COND(p_signal.name == ""); ERR_FAIL_COND_MSG(p_signal.name == "", "Signal name cannot be empty.");
ERR_FAIL_COND(ClassDB::has_signal(get_class_name(), p_signal.name)); ERR_FAIL_COND_MSG(ClassDB::has_signal(get_class_name(), p_signal.name), "User signal's name conflicts with a built-in signal of '" + get_class_name() + "'.");
ERR_FAIL_COND(signal_map.has(p_signal.name)); ERR_FAIL_COND_MSG(signal_map.has(p_signal.name), "Trying to add already existing signal '" + p_signal.name + "'.");
Signal s; Signal s;
s.user = p_signal; s.user = p_signal;
signal_map[p_signal.name] = s; signal_map[p_signal.name] = s;

View File

@ -244,7 +244,7 @@ DirAccess *DirAccess::open(const String &p_path, Error *r_error) {
DirAccess *da = create_for_path(p_path); DirAccess *da = create_for_path(p_path);
ERR_FAIL_COND_V(!da, NULL); ERR_FAIL_COND_V_MSG(!da, NULL, "Cannot create DirAccess for path '" + p_path + "'.");
Error err = da->change_dir(p_path); Error err = da->change_dir(p_path);
if (r_error) if (r_error)
*r_error = err; *r_error = err;
@ -384,39 +384,36 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
String target_dir = p_to + rel_path; String target_dir = p_to + rel_path;
if (!p_target_da->dir_exists(target_dir)) { if (!p_target_da->dir_exists(target_dir)) {
Error err = p_target_da->make_dir(target_dir); Error err = p_target_da->make_dir(target_dir);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + target_dir + "'.");
} }
Error err = change_dir(E->get()); Error err = change_dir(E->get());
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + E->get() + "'.");
err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags); err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags);
if (err) { if (err) {
change_dir(".."); change_dir("..");
ERR_PRINT("Failed to copy recursively"); ERR_FAIL_V_MSG(err, "Failed to copy recursively.");
return err;
} }
err = change_dir(".."); err = change_dir("..");
if (err) { ERR_FAIL_COND_V_MSG(err != OK, err, "Failed to go back.");
ERR_PRINT("Failed to go back");
return err;
}
} }
return OK; return OK;
} }
Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) { Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) {
ERR_FAIL_COND_V(!dir_exists(p_from), ERR_FILE_NOT_FOUND); ERR_FAIL_COND_V_MSG(!dir_exists(p_from), ERR_FILE_NOT_FOUND, "Source directory doesn't exist.");
DirAccess *target_da = DirAccess::create_for_path(p_to); DirAccess *target_da = DirAccess::create_for_path(p_to);
ERR_FAIL_COND_V(!target_da, ERR_CANT_CREATE); ERR_FAIL_COND_V_MSG(!target_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_to + "'.");
if (!target_da->dir_exists(p_to)) { if (!target_da->dir_exists(p_to)) {
Error err = target_da->make_dir_recursive(p_to); Error err = target_da->make_dir_recursive(p_to);
if (err) { if (err) {
memdelete(target_da); memdelete(target_da);
} }
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + p_to + "'.");
} }
if (!p_to.ends_with("/")) { if (!p_to.ends_with("/")) {

View File

@ -498,7 +498,7 @@ uint64_t FileAccess::get_modified_time(const String &p_file) {
return 0; return 0;
FileAccess *fa = create_for_path(p_file); FileAccess *fa = create_for_path(p_file);
ERR_FAIL_COND_V(!fa, 0); ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'.");
uint64_t mt = fa->_get_modified_time(p_file); uint64_t mt = fa->_get_modified_time(p_file);
memdelete(fa); memdelete(fa);
@ -511,7 +511,7 @@ uint32_t FileAccess::get_unix_permissions(const String &p_file) {
return 0; return 0;
FileAccess *fa = create_for_path(p_file); FileAccess *fa = create_for_path(p_file);
ERR_FAIL_COND_V(!fa, 0); ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'.");
uint32_t mt = fa->_get_unix_permissions(p_file); uint32_t mt = fa->_get_unix_permissions(p_file);
memdelete(fa); memdelete(fa);
@ -521,7 +521,7 @@ uint32_t FileAccess::get_unix_permissions(const String &p_file) {
Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) { Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) {
FileAccess *fa = create_for_path(p_file); FileAccess *fa = create_for_path(p_file);
ERR_FAIL_COND_V(!fa, ERR_CANT_CREATE); ERR_FAIL_COND_V_MSG(!fa, ERR_CANT_CREATE, "Cannot create FileAccess for path '" + p_file + "'.");
Error err = fa->_set_unix_permissions(p_file, p_permissions); Error err = fa->_set_unix_permissions(p_file, p_permissions);
memdelete(fa); memdelete(fa);
@ -599,7 +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_FAIL_V_MSG(Vector<uint8_t>(), "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) + "'.");
} }
Vector<uint8_t> data; Vector<uint8_t> data;
data.resize(f->get_len()); data.resize(f->get_len());
@ -619,7 +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_FAIL_V_MSG(String(), "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) + "'.");
} }
String ret; String ret;

View File

@ -722,7 +722,7 @@ int OS::get_audio_driver_count() const {
const char *OS::get_audio_driver_name(int p_driver) const { const char *OS::get_audio_driver_name(int p_driver) const {
AudioDriver *driver = AudioDriverManager::get_driver(p_driver); AudioDriver *driver = AudioDriverManager::get_driver(p_driver);
ERR_FAIL_COND_V(!driver, ""); ERR_FAIL_COND_V_MSG(!driver, "", "Cannot get audio driver at index '" + itos(p_driver) + "'.");
return AudioDriverManager::get_driver(p_driver)->get_name(); return AudioDriverManager::get_driver(p_driver)->get_name();
} }

View File

@ -119,7 +119,7 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b
if (rerr != OK) { if (rerr != OK) {
err = true; err = true;
ERR_FAIL_COND_V(err != OK, Variant()); ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to decode Variant.");
} }
return v; return v;
} }

View File

@ -508,7 +508,7 @@ T PoolVector<T>::operator[](int p_index) const {
template <class T> template <class T>
Error PoolVector<T>::resize(int p_size) { Error PoolVector<T>::resize(int p_size) {
ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(p_size < 0, ERR_INVALID_PARAMETER, "Size of PoolVector cannot be negative.");
if (alloc == NULL) { if (alloc == NULL) {
@ -536,7 +536,7 @@ Error PoolVector<T>::resize(int p_size) {
} else { } else {
ERR_FAIL_COND_V(alloc->lock > 0, ERR_LOCKED); //can't resize if locked! ERR_FAIL_COND_V_MSG(alloc->lock > 0, ERR_LOCKED, "Can't resize PoolVector if locked."); //can't resize if locked!
} }
size_t new_size = sizeof(T) * p_size; size_t new_size = sizeof(T) * p_size;

View File

@ -113,12 +113,12 @@ String ProjectSettings::localize_path(const String &p_path) const {
void ProjectSettings::set_initial_value(const String &p_name, const Variant &p_value) { void ProjectSettings::set_initial_value(const String &p_name, const Variant &p_value) {
ERR_FAIL_COND(!props.has(p_name)); ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
props[p_name].initial = p_value; props[p_name].initial = p_value;
} }
void ProjectSettings::set_restart_if_changed(const String &p_name, bool p_restart) { void ProjectSettings::set_restart_if_changed(const String &p_name, bool p_restart) {
ERR_FAIL_COND(!props.has(p_name)); ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
props[p_name].restart_if_changed = p_restart; props[p_name].restart_if_changed = p_restart;
} }
@ -336,7 +336,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
if (p_main_pack != "") { if (p_main_pack != "") {
bool ok = _load_resource_pack(p_main_pack); bool ok = _load_resource_pack(p_main_pack);
ERR_FAIL_COND_V(!ok, ERR_CANT_OPEN); ERR_FAIL_COND_V_MSG(!ok, ERR_CANT_OPEN, "Cannot open resource pack '" + p_main_pack + "'.");
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary"); Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
if (err == OK) { if (err == OK) {
@ -421,7 +421,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
// or, if requested (`p_upwards`) in parent directories. // or, if requested (`p_upwards`) in parent directories.
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
ERR_FAIL_COND_V(!d, ERR_CANT_CREATE); ERR_FAIL_COND_V_MSG(!d, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_path + "'.");
d->change_dir(p_path); d->change_dir(p_path);
String current_dir = d->get_current_dir(); String current_dir = d->get_current_dir();
@ -609,19 +609,19 @@ Error ProjectSettings::_load_settings_text_or_binary(const String &p_text_path,
int ProjectSettings::get_order(const String &p_name) const { int ProjectSettings::get_order(const String &p_name) const {
ERR_FAIL_COND_V(!props.has(p_name), -1); ERR_FAIL_COND_V_MSG(!props.has(p_name), -1, "Request for nonexistent project setting: " + p_name + ".");
return props[p_name].order; return props[p_name].order;
} }
void ProjectSettings::set_order(const String &p_name, int p_order) { void ProjectSettings::set_order(const String &p_name, int p_order) {
ERR_FAIL_COND(!props.has(p_name)); ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
props[p_name].order = p_order; props[p_name].order = p_order;
} }
void ProjectSettings::set_builtin_order(const String &p_name) { void ProjectSettings::set_builtin_order(const String &p_name) {
ERR_FAIL_COND(!props.has(p_name)); ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
if (props[p_name].order >= NO_BUILTIN_ORDER_BASE) { if (props[p_name].order >= NO_BUILTIN_ORDER_BASE) {
props[p_name].order = last_builtin_order++; props[p_name].order = last_builtin_order++;
} }
@ -629,7 +629,7 @@ void ProjectSettings::set_builtin_order(const String &p_name) {
void ProjectSettings::clear(const String &p_name) { void ProjectSettings::clear(const String &p_name) {
ERR_FAIL_COND(!props.has(p_name)); ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
props.erase(p_name); props.erase(p_name);
} }
@ -706,7 +706,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str
err = encode_variant(value, NULL, len, true); err = encode_variant(value, NULL, len, true);
if (err != OK) if (err != OK)
memdelete(file); memdelete(file);
ERR_FAIL_COND_V(err != OK, ERR_INVALID_DATA); ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Error when trying to encode Variant.");
Vector<uint8_t> buff; Vector<uint8_t> buff;
buff.resize(len); buff.resize(len);
@ -714,7 +714,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str
err = encode_variant(value, buff.ptrw(), len, true); err = encode_variant(value, buff.ptrw(), len, true);
if (err != OK) if (err != OK)
memdelete(file); memdelete(file);
ERR_FAIL_COND_V(err != OK, ERR_INVALID_DATA); ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Error when trying to encode Variant.");
file->store_32(len); file->store_32(len);
file->store_buffer(buff.ptr(), buff.size()); file->store_buffer(buff.ptr(), buff.size());
} }
@ -787,7 +787,7 @@ Error ProjectSettings::_save_custom_bnd(const String &p_file) { // add other par
Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_custom, const Vector<String> &p_custom_features, bool p_merge_with_current) { Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_custom, const Vector<String> &p_custom_features, bool p_merge_with_current) {
ERR_FAIL_COND_V(p_path == "", ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(p_path == "", ERR_INVALID_PARAMETER, "Project settings save path cannot be empty.");
Set<_VCSort> vclist; Set<_VCSort> vclist;

View File

@ -75,7 +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_FAIL_COND_MSG(exists, "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).");
} }
} }
path_cache = p_path; path_cache = p_path;
@ -509,7 +509,7 @@ void ResourceCache::dump(const char *p_file, bool p_short) {
FileAccess *f = NULL; FileAccess *f = NULL;
if (p_file) { if (p_file) {
f = FileAccess::open(p_file, FileAccess::WRITE); f = FileAccess::open(p_file, FileAccess::WRITE);
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "Cannot create file at path '" + String(p_file) + "'.");
} }
const String *K = NULL; const String *K = NULL;

View File

@ -181,8 +181,8 @@ public:
DummyTexture *t = texture_owner.get(p_texture); DummyTexture *t = texture_owner.get(p_texture);
ERR_FAIL_COND(!t); ERR_FAIL_COND(!t);
ERR_FAIL_COND_MSG(p_image.is_null(), "It's not a reference to a valid Image object.");
ERR_FAIL_COND(t->format != p_image->get_format()); ERR_FAIL_COND(t->format != p_image->get_format());
ERR_FAIL_COND(p_image.is_null());
ERR_FAIL_COND(src_w <= 0 || src_h <= 0); ERR_FAIL_COND(src_w <= 0 || src_h <= 0);
ERR_FAIL_COND(src_x < 0 || src_y < 0 || src_x + src_w > p_image->get_width() || src_y + src_h > p_image->get_height()); ERR_FAIL_COND(src_x < 0 || src_y < 0 || src_x + src_w > p_image->get_width() || src_y + src_h > p_image->get_height());
ERR_FAIL_COND(dst_x < 0 || dst_y < 0 || dst_x + src_w > t->width || dst_y + src_h > t->height); ERR_FAIL_COND(dst_x < 0 || dst_y < 0 || dst_x + src_w > t->width || dst_y + src_h > t->height);

View File

@ -58,7 +58,7 @@
void FileAccessUnix::check_errors() const { void FileAccessUnix::check_errors() const {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
if (feof(f)) { if (feof(f)) {
@ -76,7 +76,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
path = fix_path(p_path); path = fix_path(p_path);
//printf("opening %ls, %i\n", path.c_str(), Memory::get_static_mem_usage()); //printf("opening %ls, %i\n", path.c_str(), Memory::get_static_mem_usage());
ERR_FAIL_COND_V(f, ERR_ALREADY_IN_USE); ERR_FAIL_COND_V_MSG(f, ERR_ALREADY_IN_USE, "File is already in use.");
const char *mode_string; const char *mode_string;
if (p_mode_flags == READ) if (p_mode_flags == READ)
@ -171,7 +171,7 @@ String FileAccessUnix::get_path_absolute() const {
void FileAccessUnix::seek(size_t p_position) { void FileAccessUnix::seek(size_t p_position) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
last_error = OK; last_error = OK;
if (fseek(f, p_position, SEEK_SET)) if (fseek(f, p_position, SEEK_SET))
@ -180,7 +180,7 @@ void FileAccessUnix::seek(size_t p_position) {
void FileAccessUnix::seek_end(int64_t p_position) { void FileAccessUnix::seek_end(int64_t p_position) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
if (fseek(f, p_position, SEEK_END)) if (fseek(f, p_position, SEEK_END))
check_errors(); check_errors();
@ -188,7 +188,7 @@ void FileAccessUnix::seek_end(int64_t p_position) {
size_t FileAccessUnix::get_position() const { size_t FileAccessUnix::get_position() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
long pos = ftell(f); long pos = ftell(f);
if (pos < 0) { if (pos < 0) {
@ -200,7 +200,7 @@ size_t FileAccessUnix::get_position() const {
size_t FileAccessUnix::get_len() const { size_t FileAccessUnix::get_len() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
long pos = ftell(f); long pos = ftell(f);
ERR_FAIL_COND_V(pos < 0, 0); ERR_FAIL_COND_V(pos < 0, 0);
@ -219,7 +219,7 @@ bool FileAccessUnix::eof_reached() const {
uint8_t FileAccessUnix::get_8() const { uint8_t FileAccessUnix::get_8() const {
ERR_FAIL_COND_V(!f, 0); ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
uint8_t b; uint8_t b;
if (fread(&b, 1, 1, f) == 0) { if (fread(&b, 1, 1, f) == 0) {
check_errors(); check_errors();
@ -230,7 +230,7 @@ uint8_t FileAccessUnix::get_8() const {
int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!f, -1); ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use.");
int read = fread(p_dst, 1, p_length, f); int read = fread(p_dst, 1, p_length, f);
check_errors(); check_errors();
return read; return read;
@ -243,18 +243,19 @@ Error FileAccessUnix::get_error() const {
void FileAccessUnix::flush() { void FileAccessUnix::flush() {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
fflush(f); fflush(f);
} }
void FileAccessUnix::store_8(uint8_t p_dest) { void FileAccessUnix::store_8(uint8_t p_dest) {
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND(fwrite(&p_dest, 1, 1, f) != 1); ERR_FAIL_COND(fwrite(&p_dest, 1, 1, f) != 1);
} }
void FileAccessUnix::store_buffer(const uint8_t *p_src, int p_length) { void FileAccessUnix::store_buffer(const uint8_t *p_src, int p_length) {
ERR_FAIL_COND(!f);
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND((int)fwrite(p_src, 1, p_length, f) != p_length); ERR_FAIL_COND((int)fwrite(p_src, 1, p_length, f) != p_length);
} }

View File

@ -298,7 +298,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
} }
FILE *f = popen(argss.utf8().get_data(), "r"); FILE *f = popen(argss.utf8().get_data(), "r");
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot pipe stream from process running with following arguments '" + argss + "'.");
char buf[65535]; char buf[65535];

View File

@ -2514,7 +2514,7 @@ Error Collada::load(const String &p_path, int p_flags) {
Ref<XMLParser> parserr = memnew(XMLParser); Ref<XMLParser> parserr = memnew(XMLParser);
XMLParser &parser = *parserr.ptr(); XMLParser &parser = *parserr.ptr();
Error err = parser.open(p_path); Error err = parser.open(p_path);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err, err, "Cannot open Collada file '" + p_path + "'.");
state.local_path = ProjectSettings::get_singleton()->localize_path(p_path); state.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
state.import_flags = p_flags; state.import_flags = p_flags;
@ -2530,7 +2530,7 @@ Error Collada::load(const String &p_path, int p_flags) {
} }
} }
ERR_FAIL_COND_V(err != OK, ERR_FILE_CORRUPT); ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_CORRUPT, "Corrupted Collada file '" + p_path + "'.");
/* Start loading Collada */ /* Start loading Collada */

View File

@ -481,7 +481,7 @@ EditorPlugin *EditorData::get_editor_plugin(int p_idx) {
void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon) { void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon) {
ERR_FAIL_COND(p_script.is_null()); ERR_FAIL_COND_MSG(p_script.is_null(), "It's not a reference to a valid Script object.");
CustomType ct; CustomType ct;
ct.name = p_type; ct.name = p_type;
ct.icon = p_icon; ct.icon = p_icon;

View File

@ -151,7 +151,7 @@ void EditorDirDialog::_make_dir_confirm() {
String dir = ti->get_metadata(0); String dir = ti->get_metadata(0);
DirAccessRef d = DirAccess::open(dir); DirAccessRef d = DirAccess::open(dir);
ERR_FAIL_COND(!d); ERR_FAIL_COND_MSG(!d, "Cannot open directory '" + dir + "'.");
Error err = d->make_dir(makedirname->get_text()); Error err = d->make_dir(makedirname->get_text());
if (err != OK) { if (err != OK) {

View File

@ -913,7 +913,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c
String tmppath = EditorSettings::get_singleton()->get_cache_dir().plus_file("packtmp"); String tmppath = EditorSettings::get_singleton()->get_cache_dir().plus_file("packtmp");
FileAccess *ftmp = FileAccess::open(tmppath, FileAccess::WRITE); FileAccess *ftmp = FileAccess::open(tmppath, FileAccess::WRITE);
ERR_FAIL_COND_V(!ftmp, ERR_CANT_CREATE); ERR_FAIL_COND_V_MSG(!ftmp, ERR_CANT_CREATE, "Cannot create file '" + tmppath + "'.");
PackData pd; PackData pd;
pd.ep = &ep; pd.ep = &ep;
@ -1017,7 +1017,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

@ -165,7 +165,7 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) {
json["disabled_features"] = dis_features; json["disabled_features"] = dis_features;
FileAccessRef f = FileAccess::open(p_path, FileAccess::WRITE); FileAccessRef f = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_CREATE, "Cannot create file '" + p_path + "'.");
String text = JSON::print(json, "\t"); String text = JSON::print(json, "\t");
f->store_string(text); f->store_string(text);
@ -326,7 +326,8 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr
Vector<String> profiles; Vector<String> profiles;
DirAccessRef d = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir()); DirAccessRef d = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir());
ERR_FAIL_COND(!d); ERR_FAIL_COND_MSG(!d, "Cannot open directory '" + EditorSettings::get_singleton()->get_feature_profiles_dir() + "'.");
d->list_dir_begin(); d->list_dir_begin();
while (true) { while (true) {
String f = d->get_next(); String f = d->get_next();
@ -433,7 +434,8 @@ void EditorFeatureProfileManager::_erase_selected_profile() {
String selected = _get_selected_profile(); String selected = _get_selected_profile();
ERR_FAIL_COND(selected == String()); ERR_FAIL_COND(selected == String());
DirAccessRef da = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir()); DirAccessRef da = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir());
ERR_FAIL_COND(!da); ERR_FAIL_COND_MSG(!da, "Cannot open directory '" + EditorSettings::get_singleton()->get_feature_profiles_dir() + "'.");
da->remove(selected + ".profile"); da->remove(selected + ".profile");
if (selected == current_profile) { if (selected == current_profile) {
_profile_action(PROFILE_CLEAR); _profile_action(PROFILE_CLEAR);
@ -672,7 +674,7 @@ void EditorFeatureProfileManager::_update_selected_profile() {
//reload edited, if different from current //reload edited, if different from current
edited.instance(); edited.instance();
Error err = edited->load_from_file(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(profile + ".profile")); Error err = edited->load_from_file(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(profile + ".profile"));
ERR_FAIL_COND(err != OK); ERR_FAIL_COND_MSG(err != OK, "Error when loading EditorSettings from file '" + EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(profile + ".profile") + "'.");
} }
updating_features = true; updating_features = true;

View File

@ -326,7 +326,7 @@ void EditorFileSystem::_save_filesystem_cache() {
FileAccess *f = FileAccess::open(fscache, FileAccess::WRITE); FileAccess *f = FileAccess::open(fscache, FileAccess::WRITE);
if (f == NULL) { if (f == NULL) {
ERR_PRINTS("Error writing fscache: " + fscache); ERR_PRINTS("Error writing fscache '" + fscache + "'.");
} else { } else {
f->store_line(filesystem_settings_version_for_import); f->store_line(filesystem_settings_version_for_import);
_save_filesystem_cache(filesystem, f); _save_filesystem_cache(filesystem, f);
@ -389,7 +389,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
if (err == ERR_FILE_EOF) { if (err == ERR_FILE_EOF) {
break; break;
} else if (err != OK) { } else if (err != OK) {
ERR_PRINTS("ResourceFormatImporter::load - " + p_path + ".import:" + itos(lines) + " error: " + error_text); ERR_PRINTS("ResourceFormatImporter::load - '" + p_path + ".import:" + itos(lines) + "' error '" + error_text + "'.");
memdelete(f); memdelete(f);
return false; //parse error, try reimport manually (Avoid reimport loop on broken file) return false; //parse error, try reimport manually (Avoid reimport loop on broken file)
} }
@ -437,7 +437,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
if (err == ERR_FILE_EOF) { if (err == ERR_FILE_EOF) {
break; break;
} else if (err != OK) { } else if (err != OK) {
ERR_PRINTS("ResourceFormatImporter::load - " + p_path + ".import.md5:" + itos(lines) + " error: " + error_text); ERR_PRINTS("ResourceFormatImporter::load - '" + p_path + ".import.md5:" + itos(lines) + "' error '" + error_text + "'.");
memdelete(md5s); memdelete(md5s);
return false; // parse error return false; // parse error
} }
@ -736,7 +736,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
da->change_dir(".."); da->change_dir("..");
} }
} else { } else {
ERR_PRINTS("Cannot go into subdir: " + E->get()); ERR_PRINTS("Cannot go into subdir '" + E->get() + "'.");
} }
p_progress.update(idx, total); p_progress.update(idx, total);
@ -1555,7 +1555,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
ERR_CONTINUE(file_importer_name == String()); ERR_CONTINUE(file_importer_name == String());
if (importer_name != String() && importer_name != file_importer_name) { if (importer_name != String() && importer_name != file_importer_name) {
print_line("one importer: " + importer_name + " the other: " + file_importer_name); print_line("one importer '" + importer_name + "' the other '" + file_importer_name + "'.");
EditorNode::get_singleton()->show_warning(vformat(TTR("There are multiple importers for different types pointing to file %s, import aborted"), p_group_file)); EditorNode::get_singleton()->show_warning(vformat(TTR("There are multiple importers for different types pointing to file %s, import aborted"), p_group_file));
ERR_FAIL_V(ERR_FILE_CORRUPT); ERR_FAIL_V(ERR_FILE_CORRUPT);
} }
@ -1599,7 +1599,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
const String &file = E->key(); const String &file = E->key();
String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(file); String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(file);
FileAccessRef f = FileAccess::open(file + ".import", FileAccess::WRITE); FileAccessRef f = FileAccess::open(file + ".import", FileAccess::WRITE);
ERR_FAIL_COND_V(!f, ERR_FILE_CANT_OPEN); ERR_FAIL_COND_V_MSG(!f, ERR_FILE_CANT_OPEN, "Cannot open import file '" + file + ".import'.");
//write manually, as order matters ([remap] has to go first for performance). //write manually, as order matters ([remap] has to go first for performance).
f->store_line("[remap]"); f->store_line("[remap]");
@ -1660,7 +1660,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
// Store the md5's of the various files. These are stored separately so that the .import files can be version controlled. // Store the md5's of the various files. These are stored separately so that the .import files can be version controlled.
FileAccessRef md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE); FileAccessRef md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE);
ERR_FAIL_COND_V(!md5s, ERR_FILE_CANT_OPEN); ERR_FAIL_COND_V_MSG(!md5s, ERR_FILE_CANT_OPEN, "Cannot open MD5 file '" + base_path + ".md5'.");
md5s->store_line("source_md5=\"" + FileAccess::get_md5(file) + "\""); md5s->store_line("source_md5=\"" + FileAccess::get_md5(file) + "\"");
if (dest_paths.size()) { if (dest_paths.size()) {
@ -1671,7 +1671,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
EditorFileSystemDirectory *fs = NULL; EditorFileSystemDirectory *fs = NULL;
int cpos = -1; int cpos = -1;
bool found = _find_file(file, &fs, cpos); bool found = _find_file(file, &fs, cpos);
ERR_FAIL_COND_V(!found, ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(!found, ERR_UNCONFIGURED, "Can't find file '" + file + "'.");
//update modified times, to avoid reimport //update modified times, to avoid reimport
fs->files[cpos]->modified_time = FileAccess::get_modified_time(file); fs->files[cpos]->modified_time = FileAccess::get_modified_time(file);
@ -1705,7 +1705,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
EditorFileSystemDirectory *fs = NULL; EditorFileSystemDirectory *fs = NULL;
int cpos = -1; int cpos = -1;
bool found = _find_file(p_file, &fs, cpos); bool found = _find_file(p_file, &fs, cpos);
ERR_FAIL_COND(!found); ERR_FAIL_COND_MSG(!found, "Can't find file '" + p_file + "'.");
//try to obtain existing params //try to obtain existing params
@ -1781,13 +1781,13 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &metadata); Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &metadata);
if (err != OK) { if (err != OK) {
ERR_PRINTS("Error importing: " + p_file); ERR_PRINTS("Error importing '" + p_file + "'.");
} }
//as import is complete, save the .import file //as import is complete, save the .import file
FileAccess *f = FileAccess::open(p_file + ".import", FileAccess::WRITE); FileAccess *f = FileAccess::open(p_file + ".import", FileAccess::WRITE);
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "Cannot open file from path '" + p_file + ".import'.");
//write manually, as order matters ([remap] has to go first for performance). //write manually, as order matters ([remap] has to go first for performance).
f->store_line("[remap]"); f->store_line("[remap]");
@ -1872,7 +1872,8 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
// Store the md5's of the various files. These are stored separately so that the .import files can be version controlled. // Store the md5's of the various files. These are stored separately so that the .import files can be version controlled.
FileAccess *md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE); FileAccess *md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE);
ERR_FAIL_COND(!md5s); ERR_FAIL_COND_MSG(!md5s, "Cannot open MD5 file '" + base_path + ".md5'.");
md5s->store_line("source_md5=\"" + FileAccess::get_md5(p_file) + "\""); md5s->store_line("source_md5=\"" + FileAccess::get_md5(p_file) + "\"");
if (dest_paths.size()) { if (dest_paths.size()) {
md5s->store_line("dest_md5=\"" + FileAccess::get_multiple_md5(dest_paths) + "\"\n"); md5s->store_line("dest_md5=\"" + FileAccess::get_multiple_md5(dest_paths) + "\"\n");

View File

@ -1290,7 +1290,7 @@ void EditorInspector::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &
} }
} }
ERR_FAIL_COND(idx == -1); ERR_FAIL_COND_MSG(idx == -1, "Trying to remove nonexistent inspector plugin.");
for (int i = idx; i < inspector_plugin_count - 1; i++) { for (int i = idx; i < inspector_plugin_count - 1; i++) {
inspector_plugins[i] = inspector_plugins[i + 1]; inspector_plugins[i] = inspector_plugins[i + 1];
} }

View File

@ -903,7 +903,7 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) {
} }
Error err = cf->save(path); Error err = cf->save(path);
ERR_FAIL_COND(err != OK); ERR_FAIL_COND_MSG(err != OK, "Cannot save config file to '" + path + "'.");
} }
bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags) { bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags) {
@ -2597,7 +2597,7 @@ void EditorNode::_save_screenshot(NodePath p_path) {
img->flip_y(); img->flip_y();
viewport->set_clear_mode(Viewport::CLEAR_MODE_ALWAYS); viewport->set_clear_mode(Viewport::CLEAR_MODE_ALWAYS);
Error error = img->save_png(p_path); Error error = img->save_png(p_path);
ERR_FAIL_COND(error != OK); ERR_FAIL_COND_MSG(error != OK, "Cannot save screenshot to file '" + p_path + "'.");
} }
void EditorNode::_tool_menu_option(int p_idx) { void EditorNode::_tool_menu_option(int p_idx) {
@ -3676,7 +3676,7 @@ Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p
} }
Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const { Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const {
ERR_FAIL_COND_V(p_class.empty(), NULL); ERR_FAIL_COND_V_MSG(p_class.empty(), NULL, "Class name cannot be empty.");
if (gui_base->has_icon(p_class, "EditorIcons")) { if (gui_base->has_icon(p_class, "EditorIcons")) {
return gui_base->get_icon(p_class, "EditorIcons"); return gui_base->get_icon(p_class, "EditorIcons");

View File

@ -2038,7 +2038,7 @@ void EditorPropertyResource::_file_selected(const String &p_path) {
RES res = ResourceLoader::load(p_path); RES res = ResourceLoader::load(p_path);
ERR_FAIL_COND(res.is_null()); ERR_FAIL_COND_MSG(res.is_null(), "Cannot load resource from path '" + p_path + "'.");
List<PropertyInfo> prop_list; List<PropertyInfo> prop_list;
get_edited_object()->get_property_list(&prop_list); get_edited_object()->get_property_list(&prop_list);

View File

@ -203,7 +203,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
} }
Error err; Error err;
FileAccess *f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE, &err); FileAccess *f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE, &err);
ERR_FAIL_COND(err != OK); ERR_FAIL_COND_MSG(err != OK, "Cannot create file '" + cache_base + ".txt'.");
f->store_line(itos(thumbnail_size)); f->store_line(itos(thumbnail_size));
f->store_line(itos(has_small_texture)); f->store_line(itos(has_small_texture));
f->store_line(itos(FileAccess::get_modified_time(p_item.path))); f->store_line(itos(FileAccess::get_modified_time(p_item.path)));
@ -450,7 +450,7 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) {
} }
void EditorResourcePreview::start() { void EditorResourcePreview::start() {
ERR_FAIL_COND(thread); ERR_FAIL_COND_MSG(thread, "Thread already started.");
thread = Thread::create(_thread_func, this); thread = Thread::create(_thread_func, this);
} }

View File

@ -793,13 +793,13 @@ void EditorSettings::create() {
self_contained = true; self_contained = true;
Error err = extra_config->load(exe_path + "/._sc_"); Error err = extra_config->load(exe_path + "/._sc_");
if (err != OK) { if (err != OK) {
ERR_PRINTS("Can't load config from path: " + exe_path + "/._sc_"); ERR_PRINTS("Can't load config from path '" + exe_path + "/._sc_'.");
} }
} else if (d->file_exists(exe_path + "/_sc_")) { } else if (d->file_exists(exe_path + "/_sc_")) {
self_contained = true; self_contained = true;
Error err = extra_config->load(exe_path + "/_sc_"); Error err = extra_config->load(exe_path + "/_sc_");
if (err != OK) { if (err != OK) {
ERR_PRINTS("Can't load config from path: " + exe_path + "/_sc_"); ERR_PRINTS("Can't load config from path '" + exe_path + "/_sc_'.");
} }
} }
memdelete(d); memdelete(d);
@ -1235,10 +1235,10 @@ void EditorSettings::set_project_metadata(const String &p_section, const String
String path = get_project_settings_dir().plus_file("project_metadata.cfg"); String path = get_project_settings_dir().plus_file("project_metadata.cfg");
Error err; Error err;
err = cf->load(path); err = cf->load(path);
ERR_FAIL_COND(err != OK && err != ERR_FILE_NOT_FOUND); ERR_FAIL_COND_MSG(err != OK && err != ERR_FILE_NOT_FOUND, "Cannot load editor settings from file '" + path + "'.");
cf->set_value(p_section, p_key, p_data); cf->set_value(p_section, p_key, p_data);
err = cf->save(path); err = cf->save(path);
ERR_FAIL_COND(err != OK); ERR_FAIL_COND_MSG(err != OK, "Cannot save editor settings to file '" + path + "'.");
} }
Variant EditorSettings::get_project_metadata(const String &p_section, const String &p_key, Variant p_default) const { Variant EditorSettings::get_project_metadata(const String &p_section, const String &p_key, Variant p_default) const {

View File

@ -321,7 +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_CONTINUE_MSG(true, "Can't open file from path: " + String(to_write) + "."); ERR_CONTINUE_MSG(true, "Can't open file from path '" + String(to_write) + "'.");
} }
f->store_buffer(data.ptr(), data.size()); f->store_buffer(data.ptr(), data.size());

View File

@ -99,6 +99,6 @@ void FileTypeCache::save() {
FileTypeCache::FileTypeCache() { FileTypeCache::FileTypeCache() {
ERR_FAIL_COND(singleton); ERR_FAIL_COND_MSG(singleton, "FileTypeCache singleton already exist.");
singleton = this; singleton = this;
} }

View File

@ -1709,7 +1709,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
reimport.push_back(p_selected[i]); reimport.push_back(p_selected[i]);
} }
ERR_FAIL_COND(reimport.size() == 0); ERR_FAIL_COND_MSG(reimport.size() == 0, "You need to select files to reimport them.");
} break; } break;
case FILE_NEW_FOLDER: { case FILE_NEW_FOLDER: {
@ -2087,7 +2087,7 @@ void FileSystemDock::_get_drag_target_folder(String &target, bool &target_favori
void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<String> p_paths, bool p_display_path_dependent_options) { void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<String> p_paths, bool p_display_path_dependent_options) {
// Add options for files and folders. // Add options for files and folders.
ERR_FAIL_COND(p_paths.empty()); ERR_FAIL_COND_MSG(p_paths.empty(), "Path cannot be empty.");
Vector<String> filenames; Vector<String> filenames;
Vector<String> foldernames; Vector<String> foldernames;

View File

@ -829,7 +829,7 @@ void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result>
// however that means either losing changes or losing replaces. // however that means either losing changes or losing replaces.
FileAccess *f = FileAccess::open(fpath, FileAccess::READ); FileAccess *f = FileAccess::open(fpath, FileAccess::READ);
ERR_FAIL_COND(f == NULL); ERR_FAIL_COND_MSG(f == NULL, "Cannot open file from path '" + fpath + "'.");
String buffer; String buffer;
int current_line = 1; int current_line = 1;
@ -876,7 +876,7 @@ void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result>
// Now the modified contents are in the buffer, rewrite the file with our changes // Now the modified contents are in the buffer, rewrite the file with our changes
Error err = f->reopen(fpath, FileAccess::WRITE); Error err = f->reopen(fpath, FileAccess::WRITE);
ERR_FAIL_COND(err != OK); ERR_FAIL_COND_MSG(err != OK, "Cannot create file in path '" + fpath + "'.");
f->store_string(buffer); f->store_string(buffer);

View File

@ -1208,7 +1208,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid]; const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
mesh->set_name(meshdata.name); mesh->set_name(meshdata.name);
Error err = _create_mesh_surfaces(morphs.size() == 0, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, morph, morphs, p_use_compression, use_mesh_builtin_materials); Error err = _create_mesh_surfaces(morphs.size() == 0, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, morph, morphs, p_use_compression, use_mesh_builtin_materials);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err, err, "Cannot create mesh surface.");
mesh_cache[meshid] = mesh; mesh_cache[meshid] = mesh;
} else { } else {
@ -1260,7 +1260,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_tangents, bool p_use_compression) { Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_tangents, bool p_use_compression) {
Error err = collada.load(p_path, p_flags); Error err = collada.load(p_path, p_flags);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err, err, "Cannot load file '" + p_path + "'.");
force_make_tangents = p_force_make_tangents; force_make_tangents = p_force_make_tangents;
ERR_FAIL_COND_V(!collada.state.visual_scene_map.has(collada.state.root_visual_scene), ERR_INVALID_DATA); ERR_FAIL_COND_V(!collada.state.visual_scene_map.has(collada.state.root_visual_scene), ERR_INVALID_DATA);
@ -1778,7 +1778,7 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_
Error err = state.load(p_path, flags, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & EditorSceneImporter::IMPORT_USE_COMPRESSION); Error err = state.load(p_path, flags, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & EditorSceneImporter::IMPORT_USE_COMPRESSION);
ERR_FAIL_COND_V(err != OK, NULL); ERR_FAIL_COND_V_MSG(err != OK, NULL, "Cannot load scene from file '" + p_path + "'.");
if (state.missing_textures.size()) { if (state.missing_textures.size()) {
@ -1831,7 +1831,7 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path
state.use_mesh_builtin_materials = false; state.use_mesh_builtin_materials = false;
Error err = state.load(p_path, Collada::IMPORT_FLAG_ANIMATION, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS); Error err = state.load(p_path, Collada::IMPORT_FLAG_ANIMATION, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
ERR_FAIL_COND_V(err != OK, RES()); ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot load animation from file '" + p_path + "'.");
state.create_animations(p_flags & EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS, p_flags & EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS); state.create_animations(p_flags & EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS, p_flags & EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS);
if (state.scene) if (state.scene)

View File

@ -1670,14 +1670,14 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
track->weight_tracks.write[k] = cf; track->weight_tracks.write[k] = cf;
} }
} else { } else {
WARN_PRINTS("Invalid path: " + path); WARN_PRINTS("Invalid path '" + path + "'.");
} }
} }
state.animations.push_back(animation); state.animations.push_back(animation);
} }
print_verbose("glTF: Total animations: " + itos(state.animations.size())); print_verbose("glTF: Total animations '" + itos(state.animations.size()) + "'.");
return OK; return OK;
} }

View File

@ -90,7 +90,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ); FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ);
ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot open file from path '" + p_source_file + "'.");
Vector<String> line = f->get_csv_line(delimiter); Vector<String> line = f->get_csv_line(delimiter);
ERR_FAIL_COND_V(line.size() <= 1, ERR_PARSE_ERROR); ERR_FAIL_COND_V(line.size() <= 1, ERR_PARSE_ERROR);

View File

@ -78,7 +78,7 @@ Error ResourceImporterImage::import(const String &p_source_file, const String &p
FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ); FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ);
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file from path '" + p_source_file + "'.");
size_t len = f->get_len(); size_t len = f->get_len();
@ -90,6 +90,7 @@ Error ResourceImporterImage::import(const String &p_source_file, const String &p
memdelete(f); memdelete(f);
f = FileAccess::open(p_save_path + ".image", FileAccess::WRITE); f = FileAccess::open(p_save_path + ".image", FileAccess::WRITE);
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_CREATE, "Cannot create file in path '" + p_save_path + ".image'.");
//save the header GDIM //save the header GDIM
const uint8_t header[4] = { 'G', 'D', 'I', 'M' }; const uint8_t header[4] = { 'G', 'D', 'I', 'M' };

View File

@ -509,7 +509,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
err = ResourceSaver::save(save_path, meshes.front()->get()); err = ResourceSaver::save(save_path, meshes.front()->get());
ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save Mesh to file '" + save_path + "'.");
r_gen_files->push_back(save_path); r_gen_files->push_back(save_path);

View File

@ -1418,7 +1418,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
DirAccess *da = DirAccess::open(base_path); DirAccess *da = DirAccess::open(base_path);
Error err2 = da->make_dir(subdir_name); Error err2 = da->make_dir(subdir_name);
memdelete(da); memdelete(da);
ERR_FAIL_COND_V(err2 != OK && err2 != ERR_ALREADY_EXISTS, err2); ERR_FAIL_COND_V_MSG(err2 != OK && err2 != ERR_ALREADY_EXISTS, err2, "Cannot make directory '" + subdir_name + "'.");
base_path = base_path.plus_file(subdir_name); base_path = base_path.plus_file(subdir_name);
} }
} }
@ -1514,7 +1514,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
Ref<PackedScene> packer = memnew(PackedScene); Ref<PackedScene> packer = memnew(PackedScene);
packer->pack(child); packer->pack(child);
err = ResourceSaver::save(path, packer); //do not take over, let the changed files reload themselves err = ResourceSaver::save(path, packer); //do not take over, let the changed files reload themselves
ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save scene to file '" + path + "'.");
} }
} }
@ -1522,7 +1522,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
packer->pack(scene); packer->pack(scene);
print_verbose("Saving scene to: " + p_save_path + ".scn"); print_verbose("Saving scene to: " + p_save_path + ".scn");
err = ResourceSaver::save(p_save_path + ".scn", packer); //do not take over, let the changed files reload themselves err = ResourceSaver::save(p_save_path + ".scn", packer); //do not take over, let the changed files reload themselves
ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save scene to file '" + p_save_path + ".scn'.");
memdelete(scene); memdelete(scene);
@ -1549,7 +1549,7 @@ Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_fla
Error error; Error error;
Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error); Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error);
ERR_FAIL_COND_V(!ps.is_valid(), NULL); ERR_FAIL_COND_V_MSG(!ps.is_valid(), NULL, "Cannot load scene as text resource from path '" + p_path + "'.");
Node *scene = ps->instance(); Node *scene = ps->instance();
ERR_FAIL_COND_V(!scene, NULL); ERR_FAIL_COND_V(!scene, NULL);

View File

@ -96,7 +96,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
Error err; Error err;
FileAccess *file = FileAccess::open(p_source_file, FileAccess::READ, &err); FileAccess *file = FileAccess::open(p_source_file, FileAccess::READ, &err);
ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN); ERR_FAIL_COND_V_MSG(err != OK, ERR_CANT_OPEN, "Cannot open file '" + p_source_file + "'.");
/* CHECK RIFF */ /* CHECK RIFF */
char riff[5]; char riff[5];

View File

@ -131,7 +131,7 @@ void PluginConfigDialog::config(const String &p_config_path) {
if (p_config_path.length()) { if (p_config_path.length()) {
Ref<ConfigFile> cf = memnew(ConfigFile); Ref<ConfigFile> cf = memnew(ConfigFile);
Error err = cf->load(p_config_path); Error err = cf->load(p_config_path);
ERR_FAIL_COND(err != OK); ERR_FAIL_COND_MSG(err != OK, "Cannot load config file from path '" + p_config_path + "'.");
name_edit->set_text(cf->get_value("plugin", "name", "")); name_edit->set_text(cf->get_value("plugin", "name", ""));
subfolder_edit->set_text(p_config_path.get_base_dir().get_basename().get_file()); subfolder_edit->set_text(p_config_path.get_base_dir().get_basename().get_file());

View File

@ -734,8 +734,8 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
ERR_FAIL_COND(!player); ERR_FAIL_COND(!player);
Ref<Resource> res = ResourceLoader::load(p_file, "Animation"); Ref<Resource> res = ResourceLoader::load(p_file, "Animation");
ERR_FAIL_COND(res.is_null()); ERR_FAIL_COND_MSG(res.is_null(), "Cannot load Animation from file '" + p_file + "'.");
ERR_FAIL_COND(!res->is_class("Animation")); ERR_FAIL_COND_MSG(!res->is_class("Animation"), "Loaded resource from file '" + p_file + "' is not Animation.");
if (p_file.find_last("/") != -1) { if (p_file.find_last("/") != -1) {
p_file = p_file.substr(p_file.find_last("/") + 1, p_file.length()); p_file = p_file.substr(p_file.find_last("/") + 1, p_file.length());

View File

@ -87,7 +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_FAIL_COND_MSG(err != OK, "Error loading image: " + source_emission_file + "."); ERR_FAIL_COND_MSG(err != OK, "Error loading image '" + source_emission_file + "'.");
if (img->is_compressed()) { if (img->is_compressed()) {
img->decompress(); img->decompress();

View File

@ -779,7 +779,7 @@ bool CurvePreviewGenerator::handles(const String &p_type) const {
Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const { Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Curve> curve_ref = p_from; Ref<Curve> curve_ref = p_from;
ERR_FAIL_COND_V(curve_ref.is_null(), Ref<Texture>()); ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture>(), "It's not a reference to a valid Resource object.");
Curve &curve = **curve_ref; Curve &curve = **curve_ref;
// FIXME: Should be ported to use p_size as done in b2633a97 // FIXME: Should be ported to use p_size as done in b2633a97

View File

@ -201,7 +201,7 @@ void MeshLibraryEditor::_import_scene_cbk(const String &p_str) {
ERR_FAIL_COND(ps.is_null()); ERR_FAIL_COND(ps.is_null());
Node *scene = ps->instance(); Node *scene = ps->instance();
ERR_FAIL_COND(!scene); ERR_FAIL_COND_MSG(!scene, "Cannot create an instance from PackedScene '" + p_str + "'.");
_import_scene(scene, mesh_library, option == MENU_OPTION_UPDATE_FROM_SCENE); _import_scene(scene, mesh_library, option == MENU_OPTION_UPDATE_FROM_SCENE);

View File

@ -160,7 +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_FAIL_COND_MSG(err != OK, "Error loading image: " + source_emission_file + "."); ERR_FAIL_COND_MSG(err != OK, "Error loading image '" + source_emission_file + "'.");
if (img->is_compressed()) { if (img->is_compressed()) {
img->decompress(); img->decompress();

View File

@ -1965,7 +1965,7 @@ Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error
Ref<TextFile> text_res(text_file); Ref<TextFile> text_res(text_file);
Error err = text_file->load_text(path); Error err = text_file->load_text(path);
ERR_FAIL_COND_V(err != OK, RES()); ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot load text file '" + path + "'.");
text_file->set_file_path(local_path); text_file->set_file_path(local_path);
text_file->set_path(local_path, true); text_file->set_path(local_path, true);
@ -1990,10 +1990,7 @@ Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_p
Error err; Error err;
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err); FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
if (err) { ERR_FAIL_COND_V_MSG(err, err, "Cannot save text file '" + p_path + "'.");
ERR_FAIL_COND_V(err, err);
}
file->store_string(source); file->store_string(source);
if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) { if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {

View File

@ -192,7 +192,7 @@ void ThemeEditor::_save_template_cbk(String fname) {
FileAccess *file = FileAccess::open(filename, FileAccess::WRITE); FileAccess *file = FileAccess::open(filename, FileAccess::WRITE);
ERR_FAIL_COND_MSG(!file, "Can't save theme to file: " + filename + "."); ERR_FAIL_COND_MSG(!file, "Can't save theme to file '" + filename + "'.");
file->store_line("; ******************* "); file->store_line("; ******************* ");
file->store_line("; Template Theme File "); file->store_line("; Template Theme File ");

View File

@ -38,7 +38,7 @@
void BackgroundProgress::_add_task(const String &p_task, const String &p_label, int p_steps) { void BackgroundProgress::_add_task(const String &p_task, const String &p_label, int p_steps) {
_THREAD_SAFE_METHOD_ _THREAD_SAFE_METHOD_
ERR_FAIL_COND(tasks.has(p_task)); ERR_FAIL_COND_MSG(tasks.has(p_task), "Task '" + p_task + "' already exists.");
BackgroundProgress::Task t; BackgroundProgress::Task t;
t.hb = memnew(HBoxContainer); t.hb = memnew(HBoxContainer);
Label *l = memnew(Label); Label *l = memnew(Label);
@ -172,7 +172,7 @@ void ProgressDialog::add_task(const String &p_task, const String &p_label, int p
return; return;
} }
ERR_FAIL_COND(tasks.has(p_task)); ERR_FAIL_COND_MSG(tasks.has(p_task), "Task '" + p_task + "' already exists.");
ProgressDialog::Task t; ProgressDialog::Task t;
t.vb = memnew(VBoxContainer); t.vb = memnew(VBoxContainer);
VBoxContainer *vb2 = memnew(VBoxContainer); VBoxContainer *vb2 = memnew(VBoxContainer);

View File

@ -1182,7 +1182,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
boot_logo.instance(); boot_logo.instance();
Error load_err = ImageLoader::load_image(boot_logo_path, boot_logo); Error load_err = ImageLoader::load_image(boot_logo_path, boot_logo);
if (load_err) if (load_err)
ERR_PRINTS("Non-existing or invalid boot splash at: " + boot_logo_path + ". Loading default splash."); ERR_PRINTS("Non-existing or invalid boot splash at '" + boot_logo_path + "'. Loading default splash.");
} }
Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color); Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color);

View File

@ -282,7 +282,7 @@ void CSGShape::_update_shape() {
root_mesh.unref(); //byebye root mesh root_mesh.unref(); //byebye root mesh
CSGBrush *n = _get_brush(); CSGBrush *n = _get_brush();
ERR_FAIL_COND(!n); ERR_FAIL_COND_MSG(!n, "Cannot get CSGBrush.");
OAHashMap<Vector3, Vector3> vec_map; OAHashMap<Vector3, Vector3> vec_map;
@ -2407,7 +2407,7 @@ NodePath CSGPolygon::get_path_node() const {
} }
void CSGPolygon::set_path_interval(float p_interval) { void CSGPolygon::set_path_interval(float p_interval) {
ERR_FAIL_COND(p_interval < 0.001); ERR_FAIL_COND_MSG(p_interval < 0.001, "Path interval cannot be smaller than 0.001.");
path_interval = p_interval; path_interval = p_interval;
_make_dirty(); _make_dirty();
update_gizmo(); update_gizmo();

View File

@ -108,7 +108,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
if (r_error) if (r_error)
*r_error = ERR_FILE_CORRUPT; *r_error = ERR_FILE_CORRUPT;
ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open DDS texture file: " + p_path + "."); ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open DDS texture file '" + p_path + "'.");
uint32_t magic = f->get_32(); uint32_t magic = f->get_32();
uint32_t hsize = f->get_32(); uint32_t hsize = f->get_32();
@ -127,7 +127,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
if (magic != DDS_MAGIC || hsize != 124 || !(flags & DDSD_PIXELFORMAT) || !(flags & DDSD_CAPS)) { if (magic != DDS_MAGIC || hsize != 124 || !(flags & DDSD_PIXELFORMAT) || !(flags & DDSD_CAPS)) {
ERR_FAIL_V_MSG(RES(), "Invalid or unsupported DDS texture file: " + p_path + "."); ERR_FAIL_V_MSG(RES(), "Invalid or unsupported DDS texture file '" + p_path + "'.");
} }
/* uint32_t format_size = */ f->get_32(); /* uint32_t format_size = */ f->get_32();
@ -216,7 +216,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
} else { } else {
printf("unrecognized fourcc %x format_flags: %x - rgbbits %i - red_mask %x green mask %x blue mask %x alpha mask %x\n", format_fourcc, format_flags, format_rgb_bits, format_red_mask, format_green_mask, format_blue_mask, format_alpha_mask); printf("unrecognized fourcc %x format_flags: %x - rgbbits %i - red_mask %x green mask %x blue mask %x alpha mask %x\n", format_fourcc, format_flags, format_rgb_bits, format_red_mask, format_green_mask, format_blue_mask, format_alpha_mask);
ERR_FAIL_V_MSG(RES(), "Unrecognized or unsupported color layout in DDS: " + p_path + "."); ERR_FAIL_V_MSG(RES(), "Unrecognized or unsupported color layout in DDS '" + p_path + "'.");
} }
if (!(flags & DDSD_MIPMAPCOUNT)) if (!(flags & DDSD_MIPMAPCOUNT))

View File

@ -543,7 +543,7 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer
if (target_peer != 0) { if (target_peer != 0) {
E = peer_map.find(ABS(target_peer)); E = peer_map.find(ABS(target_peer));
ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, "Invalid target peer: " + itos(target_peer) + "."); ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, "Invalid target peer '" + itos(target_peer) + "'.");
} }
ENetPacket *packet = enet_packet_create(NULL, p_buffer_size + 8, packet_flags); ENetPacket *packet = enet_packet_create(NULL, p_buffer_size + 8, packet_flags);

View File

@ -56,14 +56,14 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path,
if (r_error) if (r_error)
*r_error = ERR_FILE_CORRUPT; *r_error = ERR_FILE_CORRUPT;
ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open PKM texture file: " + p_path + "."); ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open PKM texture file '" + p_path + "'.");
// big endian // big endian
f->set_endian_swap(true); f->set_endian_swap(true);
ETC1Header h; ETC1Header h;
f->get_buffer((uint8_t *)&h.tag, sizeof(h.tag)); f->get_buffer((uint8_t *)&h.tag, sizeof(h.tag));
ERR_FAIL_COND_V_MSG(strncmp(h.tag, "PKM 10", sizeof(h.tag)), RES(), "Invalid or unsupported PKM texture file: " + p_path + "."); ERR_FAIL_COND_V_MSG(strncmp(h.tag, "PKM 10", sizeof(h.tag)), RES(), "Invalid or unsupported PKM texture file '" + p_path + "'.");
h.format = f->get_16(); h.format = f->get_16();
h.texWidth = f->get_16(); h.texWidth = f->get_16();

View File

@ -401,9 +401,7 @@ Error PluginScript::load_source_code(const String &p_path) {
PoolVector<uint8_t> sourcef; PoolVector<uint8_t> sourcef;
Error err; Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err) { ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + p_path + "'.");
ERR_FAIL_COND_V(err, err);
}
int len = f->get_len(); int len = f->get_len();
sourcef.resize(len + 1); sourcef.resize(len + 1);

View File

@ -2177,11 +2177,11 @@ RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_ori
script->set_script_path(p_original_path); // script needs this. script->set_script_path(p_original_path); // script needs this.
script->set_path(p_original_path); script->set_path(p_original_path);
Error err = script->load_byte_code(p_path); Error err = script->load_byte_code(p_path);
ERR_FAIL_COND_V(err != OK, RES()); ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot load byte code from file '" + p_path + "'.");
} else { } else {
Error err = script->load_source_code(p_path); Error err = script->load_source_code(p_path);
ERR_FAIL_COND_V(err != OK, RES()); ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot load source code from file '" + p_path + "'.");
script->set_script_path(p_original_path); // script needs this. script->set_script_path(p_original_path); // script needs this.
script->set_path(p_original_path); script->set_path(p_original_path);
@ -2217,7 +2217,7 @@ String ResourceFormatLoaderGDScript::get_resource_type(const String &p_path) con
void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) { void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
FileAccessRef file = FileAccess::open(p_path, FileAccess::READ); FileAccessRef file = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND(!file); ERR_FAIL_COND_MSG(!file, "Cannot open file '" + p_path + "'.");
String source = file->get_as_utf8_string(); String source = file->get_as_utf8_string();
if (source.empty()) { if (source.empty()) {
@ -2244,10 +2244,7 @@ Error ResourceFormatSaverGDScript::save(const String &p_path, const RES &p_resou
Error err; Error err;
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err); FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
if (err) { ERR_FAIL_COND_V_MSG(err, err, "Cannot save GDScript file '" + p_path + "'.");
ERR_FAIL_COND_V(err, err);
}
file->store_string(source); file->store_string(source);
if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) { if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {

View File

@ -1425,7 +1425,7 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
int len; int len;
// Objects cannot be constant, never encode objects // Objects cannot be constant, never encode objects
Error err = encode_variant(E->get(), NULL, len, false); Error err = encode_variant(E->get(), NULL, len, false);
ERR_FAIL_COND_V(err != OK, Vector<uint8_t>()); ERR_FAIL_COND_V_MSG(err != OK, Vector<uint8_t>(), "Error when trying to encode Variant.");
int pos = buf.size(); int pos = buf.size();
buf.resize(pos + len); buf.resize(pos + len);
encode_variant(E->get(), &buf.write[pos], len, false); encode_variant(E->get(), &buf.write[pos], len, false);

View File

@ -55,7 +55,7 @@ Error CryptoKeyMbedTLS::load(String p_path) {
PoolByteArray out; PoolByteArray out;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ); FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot open CryptoKeyMbedTLS file '" + p_path + "'.");
int flen = f->get_len(); int flen = f->get_len();
out.resize(flen + 1); out.resize(flen + 1);
@ -69,14 +69,14 @@ Error CryptoKeyMbedTLS::load(String p_path) {
int ret = mbedtls_pk_parse_key(&pkey, out.read().ptr(), out.size(), NULL, 0); int ret = mbedtls_pk_parse_key(&pkey, out.read().ptr(), out.size(), NULL, 0);
// We MUST zeroize the memory for safety! // We MUST zeroize the memory for safety!
mbedtls_platform_zeroize(out.write().ptr(), out.size()); mbedtls_platform_zeroize(out.write().ptr(), out.size());
ERR_FAIL_COND_V_MSG(ret, FAILED, "Error parsing private key: " + itos(ret)); ERR_FAIL_COND_V_MSG(ret, FAILED, "Error parsing private key '" + itos(ret) + "'.");
return OK; return OK;
} }
Error CryptoKeyMbedTLS::save(String p_path) { Error CryptoKeyMbedTLS::save(String p_path) {
FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE); FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot save CryptoKeyMbedTLS file '" + p_path + "'.");
unsigned char w[16000]; unsigned char w[16000];
memset(w, 0, sizeof(w)); memset(w, 0, sizeof(w));
@ -85,7 +85,7 @@ Error CryptoKeyMbedTLS::save(String p_path) {
if (ret != 0) { if (ret != 0) {
memdelete(f); memdelete(f);
memset(w, 0, sizeof(w)); // Zeroize anything we might have written. memset(w, 0, sizeof(w)); // Zeroize anything we might have written.
ERR_FAIL_V_MSG(FAILED, "Error writing key: " + itos(ret)); ERR_FAIL_V_MSG(FAILED, "Error writing key '" + itos(ret) + "'.");
} }
size_t len = strlen((char *)w); size_t len = strlen((char *)w);
@ -104,7 +104,7 @@ Error X509CertificateMbedTLS::load(String p_path) {
PoolByteArray out; PoolByteArray out;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ); FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot open X509CertificateMbedTLS file '" + p_path + "'.");
int flen = f->get_len(); int flen = f->get_len();
out.resize(flen + 1); out.resize(flen + 1);
@ -131,7 +131,7 @@ Error X509CertificateMbedTLS::load_from_memory(const uint8_t *p_buffer, int p_le
Error X509CertificateMbedTLS::save(String p_path) { Error X509CertificateMbedTLS::save(String p_path) {
FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE); FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot save X509CertificateMbedTLS file '" + p_path + "'.");
mbedtls_x509_crt *crt = &cert; mbedtls_x509_crt *crt = &cert;
while (crt) { while (crt) {
@ -140,7 +140,7 @@ Error X509CertificateMbedTLS::save(String p_path) {
int ret = mbedtls_pem_write_buffer(PEM_BEGIN_CRT, PEM_END_CRT, cert.raw.p, cert.raw.len, w, sizeof(w), &wrote); int ret = mbedtls_pem_write_buffer(PEM_BEGIN_CRT, PEM_END_CRT, cert.raw.p, cert.raw.len, w, sizeof(w), &wrote);
if (ret != 0 || wrote == 0) { if (ret != 0 || wrote == 0) {
memdelete(f); memdelete(f);
ERR_FAIL_V_MSG(FAILED, "Error writing certificate: " + itos(ret)); ERR_FAIL_V_MSG(FAILED, "Error writing certificate '" + itos(ret) + "'.");
} }
f->store_buffer(w, wrote - 1); // don't write the string terminator f->store_buffer(w, wrote - 1); // don't write the string terminator

View File

@ -236,7 +236,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
} }
FileAccessRef f = FileAccess::open(p_output_file, FileAccess::WRITE); FileAccessRef f = FileAccess::open(p_output_file, FileAccess::WRITE);
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "Cannot open file '" + p_output_file + "'.");
f->store_string(JSON::print(classes_dict, /*indent: */ "\t")); f->store_string(JSON::print(classes_dict, /*indent: */ "\t"));
f->close(); f->close();

View File

@ -1195,7 +1195,7 @@ void CSharpLanguage::release_script_gchandle(MonoObject *p_expected_obj, Ref<Mon
CSharpLanguage::CSharpLanguage() { CSharpLanguage::CSharpLanguage() {
ERR_FAIL_COND(singleton); ERR_FAIL_COND_MSG(singleton, "C# singleton already exist.");
singleton = this; singleton = this;
finalizing = false; finalizing = false;
@ -3242,7 +3242,7 @@ RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED) #if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)
Error err = script->load_source_code(p_path); Error err = script->load_source_code(p_path);
ERR_FAIL_COND_V(err != OK, RES()); ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot load C# script file '" + p_path + "'.");
#endif #endif
script->set_path(p_original_path); script->set_path(p_original_path);
@ -3325,7 +3325,7 @@ Error ResourceFormatSaverCSharpScript::save(const String &p_path, const RES &p_r
Error err; Error err;
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err); FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save C# script file '" + p_path + "'.");
file->store_string(source); file->store_string(source);

View File

@ -868,7 +868,7 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir, Vect
if (!DirAccess::exists(p_proj_dir)) { if (!DirAccess::exists(p_proj_dir)) {
Error err = da->make_dir_recursive(p_proj_dir); Error err = da->make_dir_recursive(p_proj_dir);
ERR_FAIL_COND_V(err != OK, ERR_CANT_CREATE); ERR_FAIL_COND_V_MSG(err != OK, ERR_CANT_CREATE, "Cannot create directory '" + p_proj_dir + "'.");
} }
da->change_dir(p_proj_dir); da->change_dir(p_proj_dir);

View File

@ -104,7 +104,7 @@ void GDMonoLog::_delete_old_log_files(const String &p_logs_dir) {
ERR_FAIL_COND(!da); ERR_FAIL_COND(!da);
Error err = da->change_dir(p_logs_dir); Error err = da->change_dir(p_logs_dir);
ERR_FAIL_COND(err != OK); ERR_FAIL_COND_MSG(err != OK, "Cannot change directory to '" + p_logs_dir + "'.");
ERR_FAIL_COND(da->list_dir_begin() != OK); ERR_FAIL_COND(da->list_dir_begin() != OK);

View File

@ -165,7 +165,7 @@ Error read_all_file_utf8(const String &p_path, String &r_content) {
PoolVector<uint8_t> sourcef; PoolVector<uint8_t> sourcef;
Error err; Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot open file '" + p_path + "'.");
int len = f->get_len(); int len = f->get_len();
sourcef.resize(len + 1); sourcef.resize(len + 1);

View File

@ -119,9 +119,7 @@ Error AudioStreamPlaybackOpus::_load_stream() {
Error err; Error err;
f = FileAccess::open(file, FileAccess::READ, &err); f = FileAccess::open(file, FileAccess::READ, &err);
if (err) { ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + file + "'.");
ERR_FAIL_COND_V(err, err);
}
int _err = 0; int _err = 0;
@ -185,9 +183,7 @@ Error AudioStreamPlaybackOpus::set_file(const String &p_file) {
Error err; Error err;
f = FileAccess::open(file, FileAccess::READ, &err); f = FileAccess::open(file, FileAccess::READ, &err);
if (err) { ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + file + "'.");
ERR_FAIL_COND_V(err, err);
}
int _err; int _err;

View File

@ -83,7 +83,7 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin
FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ); FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ);
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file '" + p_source_file + "'.");
size_t len = f->get_len(); size_t len = f->get_len();

View File

@ -175,7 +175,7 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
memdelete(file); memdelete(file);
} }
file = FileAccess::open(p_file, FileAccess::READ); file = FileAccess::open(p_file, FileAccess::READ);
ERR_FAIL_COND(!file); ERR_FAIL_COND_MSG(!file, "Cannot open file '" + p_file + "'.");
#ifdef THEORA_USE_THREAD_STREAMING #ifdef THEORA_USE_THREAD_STREAMING
thread_exit = false; thread_exit = false;

View File

@ -242,10 +242,7 @@ Error AudioStreamPlaybackOGGVorbis::set_file(const String &p_file) {
stream_valid = false; stream_valid = false;
Error err; Error err;
f = FileAccess::open(file, FileAccess::READ, &err); f = FileAccess::open(file, FileAccess::READ, &err);
ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + p_file + "'.");
if (err) {
ERR_FAIL_COND_V(err, err);
}
int errv = ov_open_callbacks(f, &vf, NULL, 0, _ov_callbacks); int errv = ov_open_callbacks(f, &vf, NULL, 0, _ov_callbacks);
switch (errv) { switch (errv) {
@ -294,9 +291,7 @@ Error AudioStreamPlaybackOGGVorbis::_load_stream() {
Error err; Error err;
f = FileAccess::open(file, FileAccess::READ, &err); f = FileAccess::open(file, FileAccess::READ, &err);
if (err) { ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot open file '" + file + "'.");
ERR_FAIL_COND_V(err, err);
}
int errv = ov_open_callbacks(f, &vf, NULL, 0, _ov_callbacks); int errv = ov_open_callbacks(f, &vf, NULL, 0, _ov_callbacks);
switch (errv) { switch (errv) {

View File

@ -598,7 +598,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String dst_path = String("lib").plus_file(abi).plus_file(p_so.path.get_file()); String dst_path = String("lib").plus_file(abi).plus_file(p_so.path.get_file());
Vector<uint8_t> array = FileAccess::get_file_as_array(p_so.path); Vector<uint8_t> array = FileAccess::get_file_as_array(p_so.path);
Error store_err = store_in_apk(ed, dst_path, array); Error store_err = store_in_apk(ed, dst_path, array);
ERR_FAIL_COND_V(store_err, store_err); ERR_FAIL_COND_V_MSG(store_err, store_err, "Cannot store in apk file '" + dst_path + "'.");
} }
} }
if (!exported) { if (!exported) {
@ -1666,7 +1666,7 @@ public:
DirAccessRef da = DirAccess::open("res://android"); DirAccessRef da = DirAccess::open("res://android");
ERR_FAIL_COND(!da); ERR_FAIL_COND_MSG(!da, "Cannot open directory 'res://android'.");
Map<String, List<String> > directory_paths; Map<String, List<String> > directory_paths;
Map<String, List<String> > manifest_sections; Map<String, List<String> > manifest_sections;
Map<String, List<String> > gradle_sections; Map<String, List<String> > gradle_sections;
@ -1942,7 +1942,7 @@ public:
//build project if custom build is enabled //build project if custom build is enabled
String sdk_path = EDITOR_GET("export/android/custom_build_sdk_path"); String sdk_path = EDITOR_GET("export/android/custom_build_sdk_path");
ERR_FAIL_COND_V(sdk_path == "", ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(sdk_path == "", ERR_UNCONFIGURED, "Android SDK path must be configured in Editor Settings at 'export/android/custom_build_sdk_path'.");
_update_custom_build_project(); _update_custom_build_project();

View File

@ -94,13 +94,13 @@ void FileAccessJAndroid::seek(size_t p_position) {
JNIEnv *env = ThreadAndroid::get_env(); JNIEnv *env = ThreadAndroid::get_env();
ERR_FAIL_COND(!is_open()); ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use.");
env->CallVoidMethod(io, _file_seek, id, p_position); env->CallVoidMethod(io, _file_seek, id, p_position);
} }
void FileAccessJAndroid::seek_end(int64_t p_position) { void FileAccessJAndroid::seek_end(int64_t p_position) {
ERR_FAIL_COND(!is_open()); ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use.");
seek(get_len()); seek(get_len());
} }
@ -108,34 +108,34 @@ void FileAccessJAndroid::seek_end(int64_t p_position) {
size_t FileAccessJAndroid::get_position() const { size_t FileAccessJAndroid::get_position() const {
JNIEnv *env = ThreadAndroid::get_env(); JNIEnv *env = ThreadAndroid::get_env();
ERR_FAIL_COND_V(!is_open(), 0); ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
return env->CallIntMethod(io, _file_tell, id); return env->CallIntMethod(io, _file_tell, id);
} }
size_t FileAccessJAndroid::get_len() const { size_t FileAccessJAndroid::get_len() const {
JNIEnv *env = ThreadAndroid::get_env(); JNIEnv *env = ThreadAndroid::get_env();
ERR_FAIL_COND_V(!is_open(), 0); ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
return env->CallIntMethod(io, _file_get_size, id); return env->CallIntMethod(io, _file_get_size, id);
} }
bool FileAccessJAndroid::eof_reached() const { bool FileAccessJAndroid::eof_reached() const {
JNIEnv *env = ThreadAndroid::get_env(); JNIEnv *env = ThreadAndroid::get_env();
ERR_FAIL_COND_V(!is_open(), 0); ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
return env->CallIntMethod(io, _file_eof, id); return env->CallIntMethod(io, _file_eof, id);
} }
uint8_t FileAccessJAndroid::get_8() const { uint8_t FileAccessJAndroid::get_8() const {
ERR_FAIL_COND_V(!is_open(), 0); ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
uint8_t byte; uint8_t byte;
get_buffer(&byte, 1); get_buffer(&byte, 1);
return byte; return byte;
} }
int FileAccessJAndroid::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessJAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!is_open(), 0); ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
if (p_length == 0) if (p_length == 0)
return 0; return 0;
JNIEnv *env = ThreadAndroid::get_env(); JNIEnv *env = ThreadAndroid::get_env();

View File

@ -487,7 +487,7 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
String sizes; String sizes;
DirAccess *da = DirAccess::open(p_iconset_dir); DirAccess *da = DirAccess::open(p_iconset_dir);
ERR_FAIL_COND_V(!da, ERR_CANT_OPEN); ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_iconset_dir + "'.");
for (unsigned int i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { for (unsigned int i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
IconInfo info = icon_infos[i]; IconInfo info = icon_infos[i];
@ -537,7 +537,7 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPreset> &p_preset, const String &p_dest_dir) { Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPreset> &p_preset, const String &p_dest_dir) {
DirAccess *da = DirAccess::open(p_dest_dir); DirAccess *da = DirAccess::open(p_dest_dir);
ERR_FAIL_COND_V(!da, ERR_CANT_OPEN); ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_dest_dir + "'.");
for (unsigned int i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) { for (unsigned int i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) {
LoadingScreenInfo info = loading_screen_infos[i]; LoadingScreenInfo info = loading_screen_infos[i];
@ -546,7 +546,7 @@ Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPre
Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name); Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
if (err) { if (err) {
memdelete(da); memdelete(da);
String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path: " + loading_screen_file; String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path '" + loading_screen_file + "'.";
ERR_PRINT(err_str.utf8().get_data()); ERR_PRINT(err_str.utf8().get_data());
return err; return err;
} }
@ -757,7 +757,7 @@ void EditorExportPlatformIOS::_add_assets_to_project(const Ref<EditorExportPrese
Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, Vector<IOSExportAsset> &r_exported_assets) { Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, Vector<IOSExportAsset> &r_exported_assets) {
DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
ERR_FAIL_COND_V(!filesystem_da, ERR_CANT_CREATE); ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_out_dir + "'.");
for (int f_idx = 0; f_idx < p_assets.size(); ++f_idx) { for (int f_idx = 0; f_idx < p_assets.size(); ++f_idx) {
String asset = p_assets[f_idx]; String asset = p_assets[f_idx];
if (!asset.begins_with("res://")) { if (!asset.begins_with("res://")) {

View File

@ -55,7 +55,7 @@ JavaScript *JavaScript::get_singleton() {
JavaScript::JavaScript() { JavaScript::JavaScript() {
ERR_FAIL_COND(singleton != NULL); ERR_FAIL_COND_MSG(singleton != NULL, "JavaScript singleton already exist.");
singleton = this; singleton = this;
} }

View File

@ -1249,7 +1249,7 @@ public:
Error err = OK; Error err = OK;
FileAccess *fa_pack = FileAccess::open(p_path, FileAccess::WRITE, &err); FileAccess *fa_pack = FileAccess::open(p_path, FileAccess::WRITE, &err);
ERR_FAIL_COND_V(err != OK, ERR_CANT_CREATE); ERR_FAIL_COND_V_MSG(err != OK, ERR_CANT_CREATE, "Cannot create file '" + p_path + "'.");
AppxPackager packager; AppxPackager packager;
packager.init(fa_pack); packager.init(fa_pack);

View File

@ -2663,7 +2663,7 @@ String OS_Windows::get_executable_path() const {
void OS_Windows::set_native_icon(const String &p_filename) { void OS_Windows::set_native_icon(const String &p_filename) {
FileAccess *f = FileAccess::open(p_filename, FileAccess::READ); FileAccess *f = FileAccess::open(p_filename, FileAccess::READ);
ERR_FAIL_COND(!f); ERR_FAIL_COND_MSG(!f, "Cannot open file with icon '" + p_filename + "'.");
ICONDIR *icon_dir = (ICONDIR *)memalloc(sizeof(ICONDIR)); ICONDIR *icon_dir = (ICONDIR *)memalloc(sizeof(ICONDIR));
int pos = 0; int pos = 0;

View File

@ -102,7 +102,7 @@ Rect2 AnimatedSprite::_get_rect() const {
void SpriteFrames::add_frame(const StringName &p_anim, const Ref<Texture> &p_frame, int p_at_pos) { void SpriteFrames::add_frame(const StringName &p_anim, const Ref<Texture> &p_frame, int p_at_pos) {
Map<StringName, Anim>::Element *E = animations.find(p_anim); Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
if (p_at_pos >= 0 && p_at_pos < E->get().frames.size()) if (p_at_pos >= 0 && p_at_pos < E->get().frames.size())
E->get().frames.insert(p_at_pos, p_frame); E->get().frames.insert(p_at_pos, p_frame);
@ -114,7 +114,7 @@ void SpriteFrames::add_frame(const StringName &p_anim, const Ref<Texture> &p_fra
int SpriteFrames::get_frame_count(const StringName &p_anim) const { int SpriteFrames::get_frame_count(const StringName &p_anim) const {
const Map<StringName, Anim>::Element *E = animations.find(p_anim); const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V(!E, 0); ERR_FAIL_COND_V_MSG(!E, 0, "Animation '" + String(p_anim) + "' doesn't exist.");
return E->get().frames.size(); return E->get().frames.size();
} }
@ -122,7 +122,7 @@ int SpriteFrames::get_frame_count(const StringName &p_anim) const {
void SpriteFrames::remove_frame(const StringName &p_anim, int p_idx) { void SpriteFrames::remove_frame(const StringName &p_anim, int p_idx) {
Map<StringName, Anim>::Element *E = animations.find(p_anim); Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
E->get().frames.remove(p_idx); E->get().frames.remove(p_idx);
emit_changed(); emit_changed();
@ -130,7 +130,7 @@ void SpriteFrames::remove_frame(const StringName &p_anim, int p_idx) {
void SpriteFrames::clear(const StringName &p_anim) { void SpriteFrames::clear(const StringName &p_anim) {
Map<StringName, Anim>::Element *E = animations.find(p_anim); Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
E->get().frames.clear(); E->get().frames.clear();
emit_changed(); emit_changed();
@ -144,7 +144,7 @@ void SpriteFrames::clear_all() {
void SpriteFrames::add_animation(const StringName &p_anim) { void SpriteFrames::add_animation(const StringName &p_anim) {
ERR_FAIL_COND(animations.has(p_anim)); ERR_FAIL_COND_MSG(animations.has(p_anim), "SpriteFrames already has animation '" + p_anim + "'.");
animations[p_anim] = Anim(); animations[p_anim] = Anim();
animations[p_anim].normal_name = String(p_anim) + NORMAL_SUFFIX; animations[p_anim].normal_name = String(p_anim) + NORMAL_SUFFIX;
@ -161,8 +161,8 @@ void SpriteFrames::remove_animation(const StringName &p_anim) {
void SpriteFrames::rename_animation(const StringName &p_prev, const StringName &p_next) { void SpriteFrames::rename_animation(const StringName &p_prev, const StringName &p_next) {
ERR_FAIL_COND(!animations.has(p_prev)); ERR_FAIL_COND_MSG(!animations.has(p_prev), "SpriteFrames doesn't have animation '" + String(p_prev) + "'.");
ERR_FAIL_COND(animations.has(p_next)); ERR_FAIL_COND_MSG(animations.has(p_next), "Animation '" + String(p_next) + "' already exists.");
Anim anim = animations[p_prev]; Anim anim = animations[p_prev];
animations.erase(p_prev); animations.erase(p_prev);
@ -202,26 +202,26 @@ Vector<String> SpriteFrames::get_animation_names() const {
void SpriteFrames::set_animation_speed(const StringName &p_anim, float p_fps) { void SpriteFrames::set_animation_speed(const StringName &p_anim, float p_fps) {
ERR_FAIL_COND(p_fps < 0); ERR_FAIL_COND_MSG(p_fps < 0, "Animation speed cannot be negative (" + itos(p_fps) + ").");
Map<StringName, Anim>::Element *E = animations.find(p_anim); Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
E->get().speed = p_fps; E->get().speed = p_fps;
} }
float SpriteFrames::get_animation_speed(const StringName &p_anim) const { float SpriteFrames::get_animation_speed(const StringName &p_anim) const {
const Map<StringName, Anim>::Element *E = animations.find(p_anim); const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V(!E, 0); ERR_FAIL_COND_V_MSG(!E, 0, "Animation '" + String(p_anim) + "' doesn't exist.");
return E->get().speed; return E->get().speed;
} }
void SpriteFrames::set_animation_loop(const StringName &p_anim, bool p_loop) { void SpriteFrames::set_animation_loop(const StringName &p_anim, bool p_loop) {
Map<StringName, Anim>::Element *E = animations.find(p_anim); Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
E->get().loop = p_loop; E->get().loop = p_loop;
} }
bool SpriteFrames::get_animation_loop(const StringName &p_anim) const { bool SpriteFrames::get_animation_loop(const StringName &p_anim) const {
const Map<StringName, Anim>::Element *E = animations.find(p_anim); const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V(!E, false); ERR_FAIL_COND_V_MSG(!E, false, "Animation '" + String(p_anim) + "' doesn't exist.");
return E->get().loop; return E->get().loop;
} }

View File

@ -85,7 +85,7 @@ public:
_FORCE_INLINE_ Ref<Texture> get_frame(const StringName &p_anim, int p_idx) const { _FORCE_INLINE_ Ref<Texture> get_frame(const StringName &p_anim, int p_idx) const {
const Map<StringName, Anim>::Element *E = animations.find(p_anim); const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V(!E, Ref<Texture>()); ERR_FAIL_COND_V_MSG(!E, Ref<Texture>(), "Animation '" + String(p_anim) + "' doesn't exist.");
ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>()); ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>());
if (p_idx >= E->get().frames.size()) if (p_idx >= E->get().frames.size())
return Ref<Texture>(); return Ref<Texture>();
@ -96,7 +96,7 @@ public:
_FORCE_INLINE_ Ref<Texture> get_normal_frame(const StringName &p_anim, int p_idx) const { _FORCE_INLINE_ Ref<Texture> get_normal_frame(const StringName &p_anim, int p_idx) const {
const Map<StringName, Anim>::Element *E = animations.find(p_anim); const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V(!E, Ref<Texture>()); ERR_FAIL_COND_V_MSG(!E, Ref<Texture>(), "Animation '" + String(p_anim) + "' doesn't exist.");
ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>()); ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>());
const Map<StringName, Anim>::Element *EN = animations.find(E->get().normal_name); const Map<StringName, Anim>::Element *EN = animations.find(E->get().normal_name);
@ -109,7 +109,7 @@ public:
void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture> &p_frame) { void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture> &p_frame) {
Map<StringName, Anim>::Element *E = animations.find(p_anim); Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
ERR_FAIL_COND(p_idx < 0); ERR_FAIL_COND(p_idx < 0);
if (p_idx >= E->get().frames.size()) if (p_idx >= E->get().frames.size())
return; return;

Some files were not shown because too many files have changed in this diff Show More