Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/client/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ func (c *Client) UploadModel(repo *model.Repo, projectDir string) (*model.Model,
go func() {
err := uploadFile(req, "file", "model.zip", zipReader, bodyWriter)
if err != nil {
console.Fatal(err.Error())
console.Error(err.Error())
}
console.Info("Building model...")
}()

resp, err := client.Do(req)
Expand All @@ -74,6 +73,16 @@ func (c *Client) UploadModel(repo *model.Repo, projectDir string) (*model.Model,
}
defer resp.Body.Close()

if resp.StatusCode == http.StatusNotFound {
return nil, fmt.Errorf("Repository does not exist: %s", repo.String())
}
if resp.StatusCode == http.StatusUnauthorized {
return nil, fmt.Errorf("You are not authorized to write to repository %s. Did you run cog login?", repo.String())
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Server returned HTTP status %d", resp.StatusCode)
}

var mod *model.Model
reader := bufio.NewReader(resp.Body)
for {
Expand Down