From 04a3d8e5acdeccf9818549cd21dc665534424e61 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Tue, 20 May 2025 12:17:27 +0200 Subject: [PATCH] feat(ui): add error page to display errors (#5418) Signed-off-by: Ettore Di Giacinto --- core/http/endpoints/localai/gallery.go | 1 + core/http/routes/ui.go | 12 +++++- core/http/views/error.html | 56 ++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 core/http/views/error.html diff --git a/core/http/endpoints/localai/gallery.go b/core/http/endpoints/localai/gallery.go index 9dc99f5d..c2710991 100644 --- a/core/http/endpoints/localai/gallery.go +++ b/core/http/endpoints/localai/gallery.go @@ -120,6 +120,7 @@ func (mgs *ModelGalleryEndpointService) ListModelFromGalleryEndpoint() func(c *f models, err := gallery.AvailableGalleryModels(mgs.galleries, mgs.modelPath) if err != nil { + log.Error().Err(err).Msg("could not list models from galleries") return err } diff --git a/core/http/routes/ui.go b/core/http/routes/ui.go index 373a983b..7cfb1aa0 100644 --- a/core/http/routes/ui.go +++ b/core/http/routes/ui.go @@ -131,7 +131,17 @@ func RegisterUIRoutes(app *fiber.App, page := c.Query("page") items := c.Query("items") - models, _ := gallery.AvailableGalleryModels(appConfig.Galleries, appConfig.ModelPath) + models, err := gallery.AvailableGalleryModels(appConfig.Galleries, appConfig.ModelPath) + if err != nil { + log.Error().Err(err).Msg("could not list models from galleries") + return c.Status(fiber.StatusInternalServerError).Render("views/error", fiber.Map{ + "Title": "LocalAI - Models", + "BaseURL": utils.BaseURL(c), + "Version": internal.PrintableVersion(), + "ErrorCode": "500", + "ErrorMessage": err.Error(), + }) + } // Get all available tags allTags := map[string]struct{}{} diff --git a/core/http/views/error.html b/core/http/views/error.html new file mode 100644 index 00000000..83ce0438 --- /dev/null +++ b/core/http/views/error.html @@ -0,0 +1,56 @@ + + +{{template "views/partials/head" .}} + + +
+ + {{template "views/partials/navbar" .}} + +
+ +
+
+
+ +
+

+ + {{if .ErrorCode}}{{.ErrorCode}}{{else}}Error{{end}} + +

+

{{if .ErrorMessage}}{{.ErrorMessage}}{{else}}An unexpected error occurred{{end}}

+ +
+
+ + +
+
+
+ +
+

Need help?

+

Visit our 🖼️ Gallery or check the Getting started documentation

+
+
+
+ + {{template "views/partials/footer" .}} +
+ + + \ No newline at end of file