@@ -17,7 +17,7 @@ import {
1717 stopContainer ,
1818} from '../handlers/docker' ;
1919import { copyIntoVolume , downloadToVolume } from '../handlers/fs' ;
20- import { getServerState , setServerState } from '../handlers/installState' ;
20+ import { getInstallStatus , setServerState } from '../handlers/installState' ;
2121import logger from '../logger' ;
2222import { validateContainerId } from '../validation' ;
2323import { clearLogBuffer , getLogBuffer } from '../ws/server' ;
@@ -176,7 +176,7 @@ export async function handleContainerInstaller(req: Request): Promise<Response>
176176 return json ( { message : `container ${ id } installed successfully` } ) ;
177177 } catch ( error ) {
178178 logger . error ( 'error installing container' , error ) ;
179- await setServerState ( id , 'failed' ) ;
179+ await setServerState ( id , 'failed' , error instanceof Error ? error . message : String ( error ) ) ;
180180 return json ( { error : `failed to install container ${ id } ` } , 500 ) ;
181181 }
182182}
@@ -209,7 +209,7 @@ export async function handleContainerInstall(req: Request): Promise<Response> {
209209 await setServerState ( id , 'installed' ) ;
210210 } catch ( err ) {
211211 logger . error ( 'error during async install' , err ) ;
212- await setServerState ( id , 'failed' ) ;
212+ await setServerState ( id , 'failed' , err instanceof Error ? err . message : String ( err ) ) ;
213213 }
214214 } ) ( ) ;
215215
@@ -246,7 +246,7 @@ export async function handleContainerReinstall(req: Request): Promise<Response>
246246 await setServerState ( id , 'installed' ) ;
247247 } catch ( err ) {
248248 logger . error ( 'error during async reinstall' , err ) ;
249- await setServerState ( id , 'failed' ) ;
249+ await setServerState ( id , 'failed' , err instanceof Error ? err . message : String ( err ) ) ;
250250 }
251251 } ) ( ) ;
252252
@@ -347,9 +347,9 @@ export async function handleContainerInstallStatus(_req: Request, params: Record
347347 if ( ! id ) return json ( { error : 'container ID is required' } , 400 ) ;
348348 if ( ! validateContainerId ( id ) ) return json ( { error : 'invalid container ID' } , 400 ) ;
349349
350- const state = await getServerState ( id ) ;
351- if ( ! state ) return json ( { message : `no install state found for container ${ id } ` } , 404 ) ;
352- return json ( { containerId : id , state } ) ;
350+ const status = await getInstallStatus ( id ) ;
351+ if ( ! status ) return json ( { message : `no install state found for container ${ id } ` } , 404 ) ;
352+ return json ( { containerId : id , state : status . state , error : status . error } ) ;
353353}
354354
355355export async function handleContainerStart ( req : Request ) : Promise < Response > {
0 commit comments