From 7066120aaf5659a7aa5e8946beaef6e00279d5a2 Mon Sep 17 00:00:00 2001 From: Josh Yan Date: Mon, 22 Jul 2024 11:34:01 -0700 Subject: [PATCH] refactor err --- server/routes.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/routes.go b/server/routes.go index 8b5a7e2a2..5e3cdab72 100644 --- a/server/routes.go +++ b/server/routes.go @@ -614,12 +614,11 @@ func (s *Server) CreateModelHandler(c *gin.Context) { defer cancel() quantization := cmp.Or(r.Quantize, r.Quantization) - if err := CreateModel(ctx, name, filepath.Dir(r.Path), strings.ToUpper(quantization), f, fn); err != nil { - if errors.Is(err, errBadTemplate) { - ch <- gin.H{"error": err.Error(), "status": http.StatusBadRequest} - } + if err := CreateModel(ctx, name, filepath.Dir(r.Path), strings.ToUpper(quantization), f, fn); errors.Is(err, errBadTemplate) { + ch <- gin.H{"error": err.Error(), "status": http.StatusBadRequest} + } else if err != nil { ch <- gin.H{"error": err.Error()} - } + } }() if r.Stream != nil && !*r.Stream {