Add job error persistence and friendly error UI
Backend: - Migration 0003_job_error: adds error_message and error_code columns to jobs table - models/job.go: add ErrorMessage, ErrorCode fields to Job struct; SetError method; update all SELECT queries - models/job_log.go: GetAllFiltered also reads error_message and error_code (via Job embed) - syncengine/engine.go: setJobError() helper; capture errors at Wol timeout (wol_timeout), rsync error (rsync_error), and exit_code failure points - api/dto.go: add ErrorMessage and ErrorCode to JobResponse - api/handlers_jobs.go: jobToResp propagates error fields Frontend: - api/client.ts: add error_message? and error_code? to Job interface - lib/status.ts: add ERROR_CODES map with friendly titles/hints; getErrorCodeInfo() - components/ErrorDetailsModal.tsx: new modal showing error title, hint, full message, job metadata, and stderr log; copy-all and download-log buttons - pages/JobDetail.tsx: error banner for failed jobs with title/hint; View error button opens ErrorDetailsModal; SSE updates error_message in real-time
This commit is contained in:
@@ -54,3 +54,36 @@ export function statusLabel(status: string): string {
|
||||
}
|
||||
return labels[status.toLowerCase()] ?? status
|
||||
}
|
||||
|
||||
export interface ErrorCodeInfo {
|
||||
title: string;
|
||||
hint: string;
|
||||
}
|
||||
|
||||
const ERROR_CODES: Record<string, ErrorCodeInfo> = {
|
||||
wol_timeout: {
|
||||
title: "Machine didn't wake up",
|
||||
hint: 'Check Wake-on-LAN settings, MAC address, and network connectivity',
|
||||
},
|
||||
rsync_error: {
|
||||
title: 'rsync failed',
|
||||
hint: 'See the full log for rsync error details',
|
||||
},
|
||||
exit_code: {
|
||||
title: 'rsync exited with errors',
|
||||
hint: 'Check stderr output for details',
|
||||
},
|
||||
ssh_key_fallback: {
|
||||
title: 'SSH key not found',
|
||||
hint: 'Server fell back to its own key. Verify the machine SSH key configuration',
|
||||
},
|
||||
cancelled: {
|
||||
title: 'Cancelled by user',
|
||||
hint: 'The job was manually cancelled',
|
||||
},
|
||||
}
|
||||
|
||||
export function getErrorCodeInfo(code: string | null | undefined): ErrorCodeInfo | null {
|
||||
if (!code) return null
|
||||
return ERROR_CODES[code] ?? { title: code, hint: 'See full error details below' }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user