Refactor error handling in various components to ignore modal display failures and improve code clarity
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 51s

This commit is contained in:
Torsten Schulz (local)
2025-12-20 10:19:29 +01:00
parent b20b89d333
commit 42b9a10437
9 changed files with 46 additions and 17 deletions

View File

@@ -615,13 +615,17 @@ const saveConfig = async () => {
}) })
successMessage.value = 'Konfiguration erfolgreich gespeichert!' successMessage.value = 'Konfiguration erfolgreich gespeichert!'
try { window.showSuccessModal && window.showSuccessModal('Erfolg', 'Konfiguration erfolgreich gespeichert!') } catch (e) {} try { window.showSuccessModal && window.showSuccessModal('Erfolg', 'Konfiguration erfolgreich gespeichert!') } catch (_e) {
// Modal nicht verfügbar, ignorieren
}
setTimeout(() => { setTimeout(() => {
successMessage.value = '' successMessage.value = ''
}, 3000) }, 3000)
} catch (error) { } catch (error) {
errorMessage.value = error.data?.message || 'Fehler beim Speichern der Konfiguration.' errorMessage.value = error.data?.message || 'Fehler beim Speichern der Konfiguration.'
try { window.showErrorModal && window.showErrorModal('Fehler', errorMessage.value) } catch (e) {} try { window.showErrorModal && window.showErrorModal('Fehler', errorMessage.value) } catch (_e) {
// Modal nicht verfügbar, ignorieren
}
} finally { } finally {
isSaving.value = false isSaving.value = false
} }

View File

@@ -168,9 +168,13 @@ async function save() {
const updated = { ...current, seiten: { ...(current.seiten || {}), geschichte: html } } const updated = { ...current, seiten: { ...(current.seiten || {}), geschichte: html } }
try { try {
await $fetch('/api/config', { method: 'PUT', body: updated }) await $fetch('/api/config', { method: 'PUT', body: updated })
try { window.showSuccessModal && window.showSuccessModal('Erfolg', 'Inhalt erfolgreich gespeichert!') } catch (e) {} try { window.showSuccessModal && window.showSuccessModal('Erfolg', 'Inhalt erfolgreich gespeichert!') } catch (_e) {
// Modal nicht verfügbar, ignorieren
}
} catch (error) { } catch (error) {
try { window.showErrorModal && window.showErrorModal('Fehler', error?.data?.message || 'Speichern fehlgeschlagen') } catch (e) {} try { window.showErrorModal && window.showErrorModal('Fehler', error?.data?.message || 'Speichern fehlgeschlagen') } catch (_e) {
// Modal nicht verfügbar, ignorieren
}
} }
} }

View File

@@ -675,7 +675,8 @@ const loadExistingData = async () => {
} }
} }
} }
} catch (error) { } catch (_error) {
// Fehler beim Laden der Datei, ignorieren
} }
} }
</script> </script>

View File

@@ -193,9 +193,13 @@ async function save() {
const updated = { ...current, seiten: { ...(current.seiten || {}), ttRegeln: html } } const updated = { ...current, seiten: { ...(current.seiten || {}), ttRegeln: html } }
try { try {
await $fetch('/api/config', { method: 'PUT', body: updated }) await $fetch('/api/config', { method: 'PUT', body: updated })
try { window.showSuccessModal && window.showSuccessModal('Erfolg', 'Regeln erfolgreich gespeichert!') } catch (e) {} try { window.showSuccessModal && window.showSuccessModal('Erfolg', 'Regeln erfolgreich gespeichert!') } catch (_e) {
// Modal nicht verfügbar, ignorieren
}
} catch (error) { } catch (error) {
try { window.showErrorModal && window.showErrorModal('Fehler', error?.data?.message || 'Speichern fehlgeschlagen') } catch (e) {} try { window.showErrorModal && window.showErrorModal('Fehler', error?.data?.message || 'Speichern fehlgeschlagen') } catch (_e) {
// Modal nicht verfügbar, ignorieren
}
} }
} }

View File

@@ -120,9 +120,13 @@ async function save() {
const updated = { ...current, seiten: { ...(current.seiten || {}), ueberUns: html } } const updated = { ...current, seiten: { ...(current.seiten || {}), ueberUns: html } }
try { try {
await $fetch('/api/config', { method: 'PUT', body: updated }) await $fetch('/api/config', { method: 'PUT', body: updated })
try { window.showSuccessModal && window.showSuccessModal('Erfolg', 'Inhalt erfolgreich gespeichert!') } catch (e) {} try { window.showSuccessModal && window.showSuccessModal('Erfolg', 'Inhalt erfolgreich gespeichert!') } catch (_e) {
// Modal nicht verfügbar, ignorieren
}
} catch (error) { } catch (error) {
try { window.showErrorModal && window.showErrorModal('Fehler', error?.data?.message || 'Speichern fehlgeschlagen') } catch (e) {} try { window.showErrorModal && window.showErrorModal('Fehler', error?.data?.message || 'Speichern fehlgeschlagen') } catch (_e) {
// Modal nicht verfügbar, ignorieren
}
} }
} }

View File

@@ -238,8 +238,8 @@ function convertTextToHtml(text) {
if (paragraph.includes('•') || paragraph.includes('-') || paragraph.match(/^\d+\./)) { if (paragraph.includes('•') || paragraph.includes('-') || paragraph.match(/^\d+\./)) {
const listItems = paragraph.split(/\n/).map(item => { const listItems = paragraph.split(/\n/).map(item => {
item = item.trim() item = item.trim()
if (item.match(/^[•\-]\s/) || item.match(/^\d+\.\s/)) { if (item.match(/^[•-]\s/) || item.match(/^\d+\.\s/)) {
return `<li>${item.replace(/^[•\-]\s/, '').replace(/^\d+\.\s/, '')}</li>` return `<li>${item.replace(/^[•-]\s/, '').replace(/^\d+\.\s/, '')}</li>`
} }
return `<li>${item}</li>` return `<li>${item}</li>`
}).join('') }).join('')

View File

@@ -119,7 +119,9 @@ export default defineEventHandler(async (event) => {
// Titel ist Pflichtfeld // Titel ist Pflichtfeld
if (!body.title || !body.title.trim()) { if (!body.title || !body.title.trim()) {
// Lösche die hochgeladene Datei // Lösche die hochgeladene Datei
await fs.unlink(file.path).catch(() => {}) await fs.unlink(file.path).catch(() => {
// Datei bereits gelöscht oder nicht vorhanden, ignorieren
})
throw createError({ throw createError({
statusCode: 400, statusCode: 400,
statusMessage: 'Titel ist ein Pflichtfeld' statusMessage: 'Titel ist ein Pflichtfeld'

View File

@@ -39,7 +39,9 @@ function setTextFieldIfEmpty(field, val) {
const cur = field.getText() const cur = field.getText()
if (cur && String(cur).trim() !== '') return if (cur && String(cur).trim() !== '') return
} }
} catch (e) {} } catch (_e) {
// Feld nicht lesbar, ignorieren
}
if (val != null && String(val).trim() !== '') field.setText(val) if (val != null && String(val).trim() !== '') field.setText(val)
} }
@@ -58,9 +60,13 @@ function setCheckboxIfNeeded(field, name, data) {
if (mapped === 'true' || mapped === 'ja' || mapped === 'checked') { if (mapped === 'true' || mapped === 'ja' || mapped === 'checked') {
try { try {
if (!(typeof field.isChecked === 'function' && field.isChecked())) field.check && field.check() if (!(typeof field.isChecked === 'function' && field.isChecked())) field.check && field.check()
} catch (e) { field.check && field.check() } } catch (_e) {
field.check && field.check()
}
} }
} catch (e) {} } catch (_e) {
// Feld nicht verarbeitbar, ignorieren
}
} }
async function fillFormFields(pdfDoc, form, data) { async function fillFormFields(pdfDoc, form, data) {
@@ -81,7 +87,9 @@ async function fillFormFields(pdfDoc, form, data) {
try { try {
const helv2 = await pdfDoc.embedFont(StandardFonts.Helvetica) const helv2 = await pdfDoc.embedFont(StandardFonts.Helvetica)
form.updateFieldAppearances(helv2) form.updateFieldAppearances(helv2)
} catch (e) {} } catch (_e) {
// Schriftart nicht einbettbar, ignorieren
}
} }
function generateLaTeXContent(data) { function generateLaTeXContent(data) {

View File

@@ -104,7 +104,9 @@ export default defineEventHandler(async (event) => {
.toFile(newPath) .toFile(newPath)
// Temporäre Datei löschen // Temporäre Datei löschen
await fs.unlink(originalPath).catch(() => {}) await fs.unlink(originalPath).catch(() => {
// Datei bereits gelöscht oder nicht vorhanden, ignorieren
})
return { return {
success: true, success: true,