diff --git a/server/routes.go b/server/routes.go index 5c9287453..bfb49eb30 100644 --- a/server/routes.go +++ b/server/routes.go @@ -555,6 +555,15 @@ func (s *Server) GenerateHandler(c *gin.Context) { case error: c.JSON(http.StatusInternalServerError, gin.H{"error": t.Error()}) return + // TODO (jmorganca): remove use of gin.H here and instead expect + // api.StatusError to be send in the channel + case gin.H: + if msg, ok := t["error"].(string); ok { + c.JSON(http.StatusInternalServerError, gin.H{"error": msg}) + return + } + c.JSON(http.StatusInternalServerError, gin.H{"error": "unexpected response"}) + return default: c.JSON(http.StatusInternalServerError, gin.H{"error": "unexpected response"}) return @@ -2099,6 +2108,15 @@ func (s *Server) ChatHandler(c *gin.Context) { case error: c.JSON(http.StatusInternalServerError, gin.H{"error": t.Error()}) return + // TODO (jmorganca): remove use of gin.H here and instead expect + // api.StatusError to be send in the channel + case gin.H: + if msg, ok := t["error"].(string); ok { + c.JSON(http.StatusInternalServerError, gin.H{"error": msg}) + return + } + c.JSON(http.StatusInternalServerError, gin.H{"error": "unexpected response"}) + return default: c.JSON(http.StatusInternalServerError, gin.H{"error": "unexpected response"}) return