Remove all uses of ERR_EXPLAIN macros.

This commit is contained in:
Marcel Admiraal 2019-11-11 10:24:04 +01:00
parent b7fdac60f1
commit d18b2e599d
7 changed files with 17 additions and 34 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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();
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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);
}
}
}

View file

@ -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);