Make it say Issue not found

This commit is contained in:
Minecon724 2025-06-08 15:23:10 +02:00
commit 6849e914c5
Signed by untrusted user who does not match committer: m724
GPG key ID: A02E6E67AB961189
2 changed files with 19 additions and 4 deletions

View file

@ -38,6 +38,7 @@ If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
copy_error: {{ctx.Locale.Tr "copy_error"}}, copy_error: {{ctx.Locale.Tr "copy_error"}},
error_occurred: {{ctx.Locale.Tr "error.occurred"}}, error_occurred: {{ctx.Locale.Tr "error.occurred"}},
network_error: {{ctx.Locale.Tr "error.network_error"}}, 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"}}, remove_label_str: {{ctx.Locale.Tr "remove_label_str"}},
modal_confirm: {{ctx.Locale.Tr "modal.confirm"}}, modal_confirm: {{ctx.Locale.Tr "modal.confirm"}},
modal_cancel: {{ctx.Locale.Tr "modal.cancel"}}, modal_cancel: {{ctx.Locale.Tr "modal.cancel"}},

View file

@ -95,14 +95,28 @@ export default {
try { try {
const response = await GET(`${appSubUrl}/${data.owner}/${data.repo}/issues/${data.index}/info`); 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) { 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; return;
} }
this.issue = respJson; this.issue = respJson;
} catch { } catch (e) {
this.i18nErrorMessage = i18n.network_error; console.error('Error loading issue info:', e);
this.i18nErrorMessage = i18n.error_occurred; // No it is not a network error
} finally { } finally {
this.loading = false; this.loading = false;
} }