diff options
author | Yuri Sizov <yuris@humnom.net> | 2023-12-06 15:18:35 +0100 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-12-06 15:26:07 +0100 |
commit | 773b4d77644a5a75bbe326cb57e13dff3447996b (patch) | |
tree | a01ec19f8806213a2f253a8eea421cbb232436f7 /platform/web | |
parent | 2f73a059cefadcd944b6874f2557ec82e46a562d (diff) | |
download | redot-engine-773b4d77644a5a75bbe326cb57e13dff3447996b.tar.gz |
Ensure more export errors are reported to users
Also fixes the timing issue when exporting all
presets at the same time, where the error report
would try to appear while the progress dialog
was still visible.
Diffstat (limited to 'platform/web')
-rw-r--r-- | platform/web/export/export_plugin.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index a62ccdc2aa..a70812cf5b 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -259,6 +259,7 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese _replace_strings(replaces, sw); Error err = _write_or_error(sw.ptr(), sw.size(), dir.path_join(name + ".service.worker.js")); if (err != OK) { + // Message is supplied by the subroutine method. return err; } @@ -291,16 +292,19 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese const String icon144_path = p_preset->get("progressive_web_app/icon_144x144"); err = _add_manifest_icon(p_path, icon144_path, 144, icons_arr); if (err != OK) { + // Message is supplied by the subroutine method. return err; } const String icon180_path = p_preset->get("progressive_web_app/icon_180x180"); err = _add_manifest_icon(p_path, icon180_path, 180, icons_arr); if (err != OK) { + // Message is supplied by the subroutine method. return err; } const String icon512_path = p_preset->get("progressive_web_app/icon_512x512"); err = _add_manifest_icon(p_path, icon512_path, 512, icons_arr); if (err != OK) { + // Message is supplied by the subroutine method. return err; } manifest["icons"] = icons_arr; @@ -308,6 +312,7 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese CharString cs = Variant(manifest).to_json_string().utf8(); err = _write_or_error((const uint8_t *)cs.get_data(), cs.length(), dir.path_join(name + ".manifest.json")); if (err != OK) { + // Message is supplied by the subroutine method. return err; } @@ -439,6 +444,11 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p const String base_path = p_path.get_basename(); const String base_name = p_path.get_file().get_basename(); + if (!DirAccess::exists(base_dir)) { + add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Target folder does not exist or is inaccessible: \"%s\""), base_dir)); + return ERR_FILE_BAD_PATH; + } + // Find the correct template String template_path = p_debug ? custom_debug : custom_release; template_path = template_path.strip_edges(); @@ -447,10 +457,6 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p template_path = find_export_template(_get_template_name(extensions, p_debug)); } - if (!DirAccess::exists(base_dir)) { - return ERR_FILE_BAD_PATH; - } - if (!template_path.is_empty() && !FileAccess::exists(template_path)) { add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Template file not found: \"%s\"."), template_path)); return ERR_FILE_NOT_FOUND; @@ -480,6 +486,7 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p // Extract templates. error = _extract_template(template_path, base_dir, base_name, pwa); if (error) { + // Message is supplied by the subroutine method. return error; } @@ -510,6 +517,7 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p _fix_html(html, p_preset, base_name, p_debug, p_flags, shared_objects, file_sizes); Error err = _write_or_error(html.ptr(), html.size(), p_path); if (err != OK) { + // Message is supplied by the subroutine method. return err; } html.resize(0); @@ -543,6 +551,7 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p if (pwa) { err = _build_pwa(p_preset, p_path, shared_objects); if (err != OK) { + // Message is supplied by the subroutine method. return err; } } |