chore(display): error handling for opening presentations

This commit is contained in:
2025-10-21 22:23:43 +02:00
parent 4771a56164
commit da1091c173
2 changed files with 11 additions and 3 deletions
+6 -2
View File
@@ -52,9 +52,13 @@ func GetDeviceMac() (string, error) {
return "", fmt.Errorf("no suitable MAC address found") return "", fmt.Errorf("no suitable MAC address found")
} }
func OpenPresentation(path string) { func OpenPresentation(path string) error {
cmd := exec.Command("bash", "-c", "-r", fmt.Sprintf("soffice --show %s -nologo -norestore", path)) cmd := exec.Command("bash", "-c", "-r", fmt.Sprintf("soffice --show %s -nologo -norestore", path))
_ = cmd.Run() result := RunShellCommand(cmd)
if result.ExitCode != 0 {
return errors.New(result.Stderr)
}
return nil
} }
func KeyboardInput(key int) error { func KeyboardInput(key int) error {
+5 -1
View File
@@ -258,7 +258,11 @@ func openFileRoute(ctx echo.Context) error {
imageTemplate(pathParam).Render(context.Background(), &templateBuffer) imageTemplate(pathParam).Render(context.Background(), &templateBuffer)
sseConnection <- templateBuffer.String() sseConnection <- templateBuffer.String()
case ".pptx", ".odp": case ".pptx", ".odp":
pkg.OpenPresentation(fullPath) err := pkg.OpenPresentation(fullPath)
if err != nil {
slog.Error("Failed to open presentation", "file", pathParam, "error", err)
return ctx.JSON(http.StatusInternalServerError, ErrorResponse{Error: "Failed to open presentation"})
}
default: default:
return ctx.JSON(http.StatusBadRequest, ErrorResponse{Error: "Unsupported file type"}) return ctx.JSON(http.StatusBadRequest, ErrorResponse{Error: "Unsupported file type"})
} }