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

Improve DeleteSpace error messages #2297

Merged
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
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"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the message seems off

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the error the client would receive. Missing configuration for space controller error wouldn't make sense to the client. That's why I have used a generic error like 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