diff --git a/options/locale_next/locale_en-US.json b/options/locale_next/locale_en-US.json index 977cc22e49..03e75ca273 100644 --- a/options/locale_next/locale_en-US.json +++ b/options/locale_next/locale_en-US.json @@ -96,5 +96,6 @@ "settings.theme_light": "Light", "settings.theme_dark": "Dark", "settings.theme_auto": "Auto (per your browser)", + "error.issue_not_found": "Issue not found", "meta.last_line": "Thank you for translating Forgejo! This line isn't seen by the users but it serves other purposes in the translation management. You can place a fun fact in the translation instead of translating it." } diff --git a/templates/base/head_script.tmpl b/templates/base/head_script.tmpl index d2774010b6..a857f22df6 100644 --- a/templates/base/head_script.tmpl +++ b/templates/base/head_script.tmpl @@ -38,6 +38,7 @@ If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly. copy_error: {{ctx.Locale.Tr "copy_error"}}, error_occurred: {{ctx.Locale.Tr "error.occurred"}}, network_error: {{ctx.Locale.Tr "error.network_error"}}, + issue_not_found: {{ctx.Locale.Tr "error.issue_not_found"}}, remove_label_str: {{ctx.Locale.Tr "remove_label_str"}}, modal_confirm: {{ctx.Locale.Tr "modal.confirm"}}, modal_cancel: {{ctx.Locale.Tr "modal.cancel"}}, diff --git a/web_src/js/components/ContextPopup.vue b/web_src/js/components/ContextPopup.vue index 752a9a1d6b..48bd04e33b 100644 --- a/web_src/js/components/ContextPopup.vue +++ b/web_src/js/components/ContextPopup.vue @@ -95,14 +95,28 @@ export default { try { const response = await GET(`${appSubUrl}/${data.owner}/${data.repo}/issues/${data.index}/info`); - const respJson = await response.json(); + const respText = await response.text(); + + // Necesary to handle stuff like 404 that require other error messages + let respJson = {}; + try { + respJson = JSON.parse(respText); + } catch {} + if (!response.ok) { - this.i18nErrorMessage = respJson.message ?? i18n.network_error; + if (respJson.message) { + this.i18nErrorMessage = respJson.message; + } else if (response.status === 404) { + this.i18nErrorMessage = i18n.issue_not_found; + } else { + this.i18nErrorMessage = i18n.error_occurred; + } return; } this.issue = respJson; - } catch { - this.i18nErrorMessage = i18n.network_error; + } catch (e) { + console.error('Error loading issue info:', e); + this.i18nErrorMessage = i18n.error_occurred; // No it is not a network error } finally { this.loading = false; }