diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-09-25 11:51:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-25 11:51:54 +0200 |
commit | dec10dd776fca2994277faa3a97b13e70317f784 (patch) | |
tree | cea7622b2e2bb0d2cede33274807cb98b4fef856 /core/os | |
parent | de03ee94cc4df1a451c6f64e984b1da307d0f4b4 (diff) | |
parent | 17732fe698b835c29f77c84f329b2ed6cab215ce (diff) |
Merge pull request #32051 from qarmin/some_error_explanation
Added some obvious errors explanations
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/dir_access.cpp | 21 | ||||
-rw-r--r-- | core/os/file_access.cpp | 10 | ||||
-rw-r--r-- | core/os/os.cpp | 2 |
3 files changed, 15 insertions, 18 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index b444f0ae1e..e7496055ec 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -244,7 +244,7 @@ DirAccess *DirAccess::open(const String &p_path, Error *r_error) { 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); if (r_error) *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; if (!p_target_da->dir_exists(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()); - 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); if (err) { change_dir(".."); - ERR_PRINT("Failed to copy recursively"); - return err; + ERR_FAIL_V_MSG(err, "Failed to copy recursively."); } err = change_dir(".."); - if (err) { - ERR_PRINT("Failed to go back"); - return err; - } + ERR_FAIL_COND_V_MSG(err != OK, err, "Failed to go back."); } return OK; } 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); - 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)) { Error err = target_da->make_dir_recursive(p_to); if (err) { 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("/")) { diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 9a8315a3bb..738e597730 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -498,7 +498,7 @@ uint64_t FileAccess::get_modified_time(const String &p_file) { return 0; 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); memdelete(fa); @@ -511,7 +511,7 @@ uint32_t FileAccess::get_unix_permissions(const String &p_file) { return 0; 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); 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) { 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); 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 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; 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) { 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; diff --git a/core/os/os.cpp b/core/os/os.cpp index 7531900480..b44487b908 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -722,7 +722,7 @@ int OS::get_audio_driver_count() const { const char *OS::get_audio_driver_name(int p_driver) const { 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(); } |