From 708bd7920060c02a02c62c9bd94a8be5716a7477 Mon Sep 17 00:00:00 2001 From: br0kenpixel <23280129+br0kenpixel@users.noreply.github.com> Date: Sat, 8 Nov 2025 14:06:51 +0100 Subject: [PATCH] fix: simplify error handling for `FetchError` in various components --- frontend/app/pages/account/activation/[token].vue | 2 +- .../app/pages/dashboard/admin/internships/edit/[id].vue | 2 +- frontend/app/pages/dashboard/admin/students/edit/[id].vue | 3 --- .../app/pages/dashboard/student/internship/create.vue | 7 +++++-- frontend/app/pages/login.vue | 2 +- frontend/app/pages/register/company.vue | 7 +++++-- frontend/app/pages/register/student.vue | 7 +++++-- frontend/app/pages/reset_psw/index.vue | 8 ++++++-- 8 files changed, 24 insertions(+), 14 deletions(-) diff --git a/frontend/app/pages/account/activation/[token].vue b/frontend/app/pages/account/activation/[token].vue index 45edf0d..f083598 100644 --- a/frontend/app/pages/account/activation/[token].vue +++ b/frontend/app/pages/account/activation/[token].vue @@ -43,7 +43,7 @@ async function handleLogin() { success.value = true; } catch (e) { - if (e instanceof FetchError && e.response?.status === 422) { + if (e instanceof FetchError) { error.value = e.response?._data.message; } } finally { diff --git a/frontend/app/pages/dashboard/admin/internships/edit/[id].vue b/frontend/app/pages/dashboard/admin/internships/edit/[id].vue index 6b9c4cc..f74d4e2 100644 --- a/frontend/app/pages/dashboard/admin/internships/edit/[id].vue +++ b/frontend/app/pages/dashboard/admin/internships/edit/[id].vue @@ -33,7 +33,7 @@ async function handleUpdateOfBasicInfo(internship: NewInternship) { navigateTo("/dashboard/admin/internships"); } catch (e) { - if (e instanceof FetchError && (e.response?.status === 422 || e.response?.status === 400)) { + if (e instanceof FetchError) { action_error.value = e.response?._data.message; } } finally { diff --git a/frontend/app/pages/dashboard/admin/students/edit/[id].vue b/frontend/app/pages/dashboard/admin/students/edit/[id].vue index 72c3bb7..2a668a6 100644 --- a/frontend/app/pages/dashboard/admin/students/edit/[id].vue +++ b/frontend/app/pages/dashboard/admin/students/edit/[id].vue @@ -64,7 +64,6 @@ async function saveChanges() { navigateTo("/dashboard/admin/students"); } catch (e) { if (e instanceof FetchError) { - console.error('Error saving student:', e.response?._data.message); alert('Chyba:\n' + e.response?._data.message); } } finally { @@ -111,8 +110,6 @@ const deleteStudent = async () => { } catch (e) { if (e instanceof FetchError) { deleteError.value = e.response?._data?.message || 'Chyba pri mazaní študenta.'; - } else { - deleteError.value = 'Neznáma chyba pri mazaní študenta.'; } } finally { deleteLoading.value = false; diff --git a/frontend/app/pages/dashboard/student/internship/create.vue b/frontend/app/pages/dashboard/student/internship/create.vue index acd2b46..cf349da 100644 --- a/frontend/app/pages/dashboard/student/internship/create.vue +++ b/frontend/app/pages/dashboard/student/internship/create.vue @@ -1,5 +1,6 @@