Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.
TypeScript
fix: surface actual error message when service installation fails
Tom Boucher6b558531be11
diff --git a/admin/app/controllers/system_controller.ts b/admin/app/controllers/system_controller.tsindex 0c3e1ada..fbc872a3 100644--- a/admin/app/controllers/system_controller.ts+++ b/admin/app/controllers/system_controller.ts@@ -35,7 +35,7 @@ export default class SystemController {if (result.success) {response.send({ success: true, message: result.message });} else {- response.status(400).send({ error: result.message });+ response.status(400).send({ success: false, message: result.message });}}diff --git a/admin/inertia/lib/api.ts b/admin/inertia/lib/api.tsindex 026d44db..a47f3260 100644--- a/admin/inertia/lib/api.ts+++ b/admin/inertia/lib/api.ts@@ -1,4 +1,4 @@-import axios, { AxiosInstance } from 'axios'+import axios, { AxiosError, AxiosInstance } from 'axios'import { ListRemoteZimFilesResponse, ListZimFilesResponse } from '../../types/zim'import { ServiceSlim } from '../../types/services'import { FileEntry } from '../../types/files'@@ -25,13 +25,19 @@ class API {}async affectService(service_name: string, action: 'start' | 'stop' | 'restart') {- return catchInternal(async () => {+ try {const response = await this.client.post<{ success: boolean; message: string }>('/system/services/affect',{ service_name, action })return response.data- })()+ } catch (error) {+ if (error instanceof AxiosError && error.response?.data?.message) {+ return { success: false, message: error.response.data.message }+ }+ console.error('Error affecting service:', error)+ return undefined+ }}async checkLatestVersion(force: boolean = false) {@@ -192,13 +198,19 @@ class API {}async forceReinstallService(service_name: string) {- return catchInternal(async () => {+ try {const response = await this.client.post<{ success: boolean; message: string }>(`/system/services/force-reinstall`,{ service_name })return response.data- })()+ } catch (error) {+ if (error instanceof AxiosError && error.response?.data?.message) {+ return { success: false, message: error.response.data.message }+ }+ console.error('Error force reinstalling service:', error)+ return undefined+ }}async getChatSuggestions(signal?: AbortSignal) {@@ -459,13 +471,19 @@ class API {}async installService(service_name: string) {- return catchInternal(async () => {+ try {const response = await this.client.post<{ success: boolean; message: string }>('/system/services/install',{ service_name })return response.data- })()+ } catch (error) {+ if (error instanceof AxiosError && error.response?.data?.message) {+ return { success: false, message: error.response.data.message }+ }+ console.error('Error installing service:', error)+ return undefined+ }}async listCuratedMapCollections() {