Skip to content

Commit

Permalink
Improve DeleteSpace error messages (fabric8-services#2297)
Browse files Browse the repository at this point in the history
Minor improvements to errors returned from the Detele action on space controller.
  • Loading branch information
jarifibrahim authored and kwk committed Sep 25, 2018
1 parent fce0b6a commit 07f931d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions controller/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ func (c *SpaceController) Delete(ctx *app.DeleteSpaceContext) error {
return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
}

spaceDeletionErrorExternal := fmt.Errorf("could not delete space")
spaceID, err := goauuid.FromString(ctx.SpaceID.String())
if err != nil {
log.Error(ctx, map[string]interface{}{
"space_id": ctx.SpaceID,
"error": err,
}, "could not convert the UUID of type github.com/satori/go.uuid to github.com/goadesign/goa/uuid")
return jsonapi.JSONErrorResponse(
ctx, errors.NewInternalError(ctx, spaceDeletionErrorExternal))
ctx, errors.NewInternalError(ctx, errs.Wrap(err, "could not delete space")),
)
}

// extract config in it's generic form to be utilized elsewhere
Expand All @@ -201,7 +201,8 @@ func (c *SpaceController) Delete(ctx *app.DeleteSpaceContext) error {
"space_id": spaceID,
}, "no configuation found in SpaceController object")
return jsonapi.JSONErrorResponse(
ctx, errors.NewInternalError(ctx, spaceDeletionErrorExternal))
ctx, errors.NewInternalErrorFromString("could not delete space"),
)
}

// delete all the codebases associated with this space
Expand All @@ -225,7 +226,10 @@ func (c *SpaceController) Delete(ctx *app.DeleteSpaceContext) error {
"error": err,
}, "could not delete OpenShift resources")
return jsonapi.JSONErrorResponse(
ctx, errors.NewInternalError(ctx, err))
ctx, errors.NewInternalError(ctx, errs.Wrapf(
err, "could not delete Openshift resources associated with space %s", spaceID),
),
)
}
}

Expand Down

0 comments on commit 07f931d

Please sign in to comment.