浏览代码

bad request to templ err

Josh Yan 9 月之前
父节点
当前提交
3e89435605
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      server/routes.go

+ 5 - 1
server/routes.go

@@ -614,7 +614,11 @@ func (s *Server) CreateModelHandler(c *gin.Context) {
 
 		quantization := cmp.Or(r.Quantize, r.Quantization)
 		if err := CreateModel(ctx, name, filepath.Dir(r.Path), strings.ToUpper(quantization), f, fn); err != nil {
-			ch <- gin.H{"error": err.Error()}
+			if strings.HasPrefix(err.Error(), "template: ") {
+				c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+			} else {
+				ch <- gin.H{"error": err.Error()}
+			}
 		}
 	}()