From 17eaf37ff7e243239e8a983a25d5b9bf64f25f23 Mon Sep 17 00:00:00 2001 From: andreasjansson Date: Mon, 3 May 2021 17:51:49 -0700 Subject: [PATCH] Catch error when server dies to avoid spewing logs Signed-off-by: andreasjansson --- pkg/client/upload.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/client/upload.go b/pkg/client/upload.go index d3f3e16cfe..1ad36dd4f6 100644 --- a/pkg/client/upload.go +++ b/pkg/client/upload.go @@ -92,8 +92,11 @@ func (c *Client) UploadModel(repo *model.Repo, projectDir string) (*model.Model, break } if err == io.ErrUnexpectedEOF { - console.Warn("Unexpected EOF") - break + return nil, fmt.Errorf("Unexpected EOF") + } + // TODO(andreas): how to catch this error without comparing strings? + if strings.Contains(err.Error(), "stream error") && strings.Contains(err.Error(), "INTERNAL_ERROR") { + return nil, fmt.Errorf("Lost contact with server. Please try again") } console.Warn(err.Error()) }