Skip to content

Commit

Permalink
Add error checking to critical params
Browse files Browse the repository at this point in the history
  • Loading branch information
jdsutherland committed Jan 2, 2019
1 parent e6f67ef commit 9e94e35
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ func (ctx *submitContext) documents(exerciseDir string) ([]workspace.Document, e
}

func (ctx *submitContext) writeFormFiles(writer *multipart.Writer, docs []workspace.Document) error {
if writer == nil {
return errors.New("writer is empty")
}
if len(docs) == 0 {
return errors.New("docs is empty")
}

for _, doc := range docs {
file, err := os.Open(doc.Filepath())
if err != nil {
Expand All @@ -299,6 +306,13 @@ func (ctx *submitContext) writeFormFiles(writer *multipart.Writer, docs []worksp
}

func (ctx *submitContext) submitRequest(id string, writer *multipart.Writer, body *bytes.Buffer) error {
if writer == nil {
return errors.New("writer is empty")
}
if body.Len() == 0 {
return errors.New("body is empty")
}

client, err := api.NewClient(ctx.usrCfg.GetString("token"), ctx.usrCfg.GetString("apibaseurl"))
if err != nil {
return err
Expand Down

0 comments on commit 9e94e35

Please sign in to comment.