Преглед на файлове

Remove all uses of ERR_EXPLAIN macros.

Marcel Admiraal преди 5 години
родител
ревизия
d18b2e599d

+ 3 - 6
core/os/memory.cpp

@@ -50,20 +50,17 @@ void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)) {
 #ifdef _MSC_VER
 void operator delete(void *p_mem, const char *p_description) {
 
-	ERR_EXPLAINC("Call to placement delete should not happen.");
-	CRASH_NOW();
+	CRASH_NOW_MSG("Call to placement delete should not happen.");
 }
 
 void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size)) {
 
-	ERR_EXPLAINC("Call to placement delete should not happen.");
-	CRASH_NOW();
+	CRASH_NOW_MSG("Call to placement delete should not happen.");
 }
 
 void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description) {
 
-	ERR_EXPLAINC("Call to placement delete should not happen.");
-	CRASH_NOW();
+	CRASH_NOW_MSG("Call to placement delete should not happen.");
 }
 #endif
 

+ 4 - 5
drivers/png/png_driver_common.cpp

@@ -43,7 +43,6 @@ namespace PNGDriverCommon {
 static bool check_error(const png_image &image) {
 	const png_uint_32 failed = PNG_IMAGE_FAILED(image);
 	if (failed & PNG_IMAGE_ERROR) {
-		ERR_EXPLAINC(image.message);
 		return true;
 	} else if (failed) {
 #ifdef TOOLS_ENABLED
@@ -67,7 +66,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
 
 	// fetch image properties
 	int success = png_image_begin_read_from_memory(&png_img, p_source, p_size);
-	ERR_FAIL_COND_V(check_error(png_img), ERR_FILE_CORRUPT);
+	ERR_FAIL_COND_V_MSG(check_error(png_img), ERR_FILE_CORRUPT, png_img.message);
 	ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT);
 
 	// flags to be masked out of input format to give target format
@@ -112,7 +111,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
 
 	// read image data to buffer and release libpng resources
 	success = png_image_finish_read(&png_img, NULL, writer.ptr(), stride, NULL);
-	ERR_FAIL_COND_V(check_error(png_img), ERR_FILE_CORRUPT);
+	ERR_FAIL_COND_V_MSG(check_error(png_img), ERR_FILE_CORRUPT, png_img.message);
 	ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT);
 
 	p_image->create(png_img.width, png_img.height, 0, dest_format, buffer);
@@ -176,7 +175,7 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
 		PoolVector<uint8_t>::Write writer = p_buffer.write();
 		success = png_image_write_to_memory(&png_img, &writer[buffer_offset],
 				&compressed_size, 0, reader.ptr(), 0, NULL);
-		ERR_FAIL_COND_V(check_error(png_img), FAILED);
+		ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
 	}
 	if (!success) {
 
@@ -190,7 +189,7 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
 		PoolVector<uint8_t>::Write writer = p_buffer.write();
 		success = png_image_write_to_memory(&png_img, &writer[buffer_offset],
 				&compressed_size, 0, reader.ptr(), 0, NULL);
-		ERR_FAIL_COND_V(check_error(png_img), FAILED);
+		ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
 		ERR_FAIL_COND_V(!success, FAILED);
 	}
 

+ 4 - 15
editor/plugins/version_control_editor_plugin.cpp

@@ -106,29 +106,20 @@ void VersionControlEditorPlugin::_initialize_vcs() {
 
 	register_editor();
 
-	if (EditorVCSInterface::get_singleton()) {
-
-		ERR_EXPLAIN(EditorVCSInterface::get_singleton()->get_vcs_name() + " is already active");
-		return;
-	}
+	ERR_FAIL_COND_MSG(EditorVCSInterface::get_singleton(), EditorVCSInterface::get_singleton()->get_vcs_name() + " is already active");
 
 	const int id = set_up_choice->get_selected_id();
 	String selected_addon = set_up_choice->get_item_text(id);
 
 	String path = ScriptServer::get_global_class_path(selected_addon);
 	Ref<Script> script = ResourceLoader::load(path);
-	if (!script.is_valid()) {
 
-		ERR_EXPLAIN("VCS Addon path is invalid");
-	}
+	ERR_FAIL_COND_MSG(!script.is_valid(), "VCS Addon path is invalid");
 
 	EditorVCSInterface *vcs_interface = memnew(EditorVCSInterface);
 	ScriptInstance *addon_script_instance = script->instance_create(vcs_interface);
-	if (!addon_script_instance) {
 
-		ERR_FAIL_NULL(addon_script_instance);
-		return;
-	}
+	ERR_FAIL_COND_MSG(!addon_script_instance, "Failed to create addon script instance.");
 
 	// The addon is attached as a script to the VCS interface as a proxy end-point
 	vcs_interface->set_script_and_instance(script.get_ref_ptr(), addon_script_instance);
@@ -137,10 +128,8 @@ void VersionControlEditorPlugin::_initialize_vcs() {
 	EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_refresh_stage_area");
 
 	String res_dir = OS::get_singleton()->get_resource_dir();
-	if (!EditorVCSInterface::get_singleton()->initialize(res_dir)) {
 
-		ERR_EXPLAIN("VCS was not initialized");
-	}
+	ERR_FAIL_COND_MSG(!EditorVCSInterface::get_singleton()->initialize(res_dir), "VCS was not initialized");
 
 	_refresh_stage_area();
 }

+ 3 - 2
modules/assimp/editor_scene_importer_assimp.cpp

@@ -148,8 +148,9 @@ Node *EditorSceneImporterAssimp::import_scene(const String &p_path, uint32_t p_f
 								 //aiProcess_SplitByBoneCount |
 								 0;
 	aiScene *scene = (aiScene *)importer.ReadFile(s_path.c_str(), post_process_Steps);
-	ERR_EXPLAIN(String("Open Asset Import failed to open: ") + String(importer.GetErrorString()));
-	ERR_FAIL_COND_V(scene == NULL, NULL);
+
+	ERR_FAIL_COND_V_MSG(scene == NULL, NULL, String("Open Asset Import failed to open: ") + String(importer.GetErrorString()));
+
 	return _generate_scene(p_path, scene, p_flags, p_bake_fps, max_bone_weights);
 }
 

+ 1 - 2
modules/assimp/import_utils.h

@@ -369,8 +369,7 @@ public:
 					state.path_to_image_cache.insert(p_path, img);
 					return img;
 				} else if (tex->CheckFormat("dds")) {
-					ERR_EXPLAIN("Open Asset Import: Embedded dds not implemented");
-					ERR_FAIL_COND_V(true, Ref<Image>());
+					ERR_FAIL_COND_V_MSG(true, Ref<Image>(), "Open Asset Import: Embedded dds not implemented");
 				}
 			} else {
 				Ref<Image> img;

+ 1 - 2
modules/gdscript/language_server/gdscript_workspace.cpp

@@ -117,8 +117,7 @@ void GDScriptWorkspace::reload_all_workspace_scripts() {
 			if (S) {
 				err_msg += "\n" + S->get()->get_error();
 			}
-			ERR_EXPLAIN(err_msg);
-			ERR_CONTINUE(err != OK);
+			ERR_CONTINUE_MSG(err != OK, err_msg);
 		}
 	}
 }

+ 1 - 2
modules/xatlas_unwrap/register_types.cpp

@@ -65,8 +65,7 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
 	xatlas::Atlas *atlas = xatlas::Create();
 	printf("Adding mesh..\n");
 	xatlas::AddMeshError::Enum err = xatlas::AddMesh(atlas, input_mesh, 1);
-	ERR_EXPLAINC(xatlas::StringForEnum(err));
-	ERR_FAIL_COND_V(err != xatlas::AddMeshError::Enum::Success, false);
+	ERR_FAIL_COND_V_MSG(err != xatlas::AddMeshError::Enum::Success, false, xatlas::StringForEnum(err));
 
 	printf("Generate..\n");
 	xatlas::Generate(atlas, chart_options, NULL, pack_options);