Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
checks for result of type conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
DhritiShikhar committed Oct 23, 2018
1 parent f9d6c10 commit 41bc004
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions controller/workitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ func (c *WorkitemController) Update(ctx *app.UpdateWorkitemContext) error {
if creator == nil {
return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError(ctx, errs.New("work item doesn't have creator")))
}
creatorID, err := uuid.FromString(creator.(string))
creatorIDStr, ok := creator.(string)
if !ok {
return jsonapi.JSONErrorResponse(ctx, errs.Errorf("failed to convert user to string: %+v (%[1]T)", creator))
}
creatorID, err := uuid.FromString(creatorIDStr)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, err)
}
Expand Down Expand Up @@ -257,7 +261,11 @@ func (c *WorkitemController) Delete(ctx *app.DeleteWorkitemContext) error {
if creator == nil {
return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError(ctx, errs.New("work item doesn't have creator")))
}
creatorID, err := uuid.FromString(creator.(string))
creatorIDStr, ok := creator.(string)
if !ok {
return jsonapi.JSONErrorResponse(ctx, errs.Errorf("failed to convert user to string: %+v (%[1]T)", creator))
}
creatorID, err := uuid.FromString(creatorIDStr)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, err)
}
Expand Down

0 comments on commit 41bc004

Please sign in to comment.