Fix duplicate organization name returning internal error
When creating an organization with a name that produces a duplicate trust center slug, the API now returns a Conflict response instead of a generic Internal error. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -779,6 +779,10 @@ func (r *mutationResolver) CreateOrganization(ctx context.Context, input types.C
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create organization", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user