From a2e44af6bde7c1443bf78335935ff99665bb0b67 Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Mon, 26 Jan 2026 12:27:35 +0200 Subject: [PATCH] fix: roles error handling on admin ui --- src/AdminSettings.vue | 7 +++++++ src/axios.ts | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/AdminSettings.vue b/src/AdminSettings.vue index 19b660d..f3a0063 100644 --- a/src/AdminSettings.vue +++ b/src/AdminSettings.vue @@ -29,6 +29,10 @@ {{ strings.userRolesHelp }} + + {{ rolesError }} + +
@@ -111,6 +115,7 @@ export default { // User roles rolesLoading: true, + rolesError: null, roles: [], userId: '', selectedRole: null, @@ -157,10 +162,12 @@ export default { async fetchRoles() { try { this.rolesLoading = true + this.rolesError = null const resp = await ocs.get('/admin/roles') this.roles = resp.data.roles } catch (e) { console.error('Failed to fetch roles', e) + this.rolesError = e.response?.data?.message || t('forum', 'Failed to fetch roles') } finally { this.rolesLoading = false } diff --git a/src/axios.ts b/src/axios.ts index 8a7284b..ab372e6 100644 --- a/src/axios.ts +++ b/src/axios.ts @@ -16,7 +16,11 @@ ocs.interceptors.response.use( if (ocsResponse !== undefined) { // Extract data from OCS response, falling back to meta message for errors const ocsData = ocsResponse.data - if (ocsData !== undefined && ocsData !== null) { + const isEmpty = + ocsData === undefined || + ocsData === null || + (Array.isArray(ocsData) && ocsData.length === 0) + if (!isEmpty) { error.response.data = ocsData } else if (ocsResponse.meta?.message) { // For OCS errors that only have meta message (no data)