distinguish badrequest and conflict / already exists errors

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2020-11-05 13:06:05 +01:00
parent 6382cdae3a
commit cac8f2ef04
2 changed files with 7 additions and 4 deletions
+2 -2
View File
@@ -312,7 +312,7 @@ func (s Service) CreateAccount(ctx context.Context, in *proto.CreateAccountReque
return merrors.InternalServerError(s.id, "could not check if account exists: %v", err.Error())
}
if exists {
return merrors.BadRequest(s.id, "account already exists")
return merrors.Conflict(s.id, "account already exists")
}
if out.PasswordProfile != nil {
@@ -342,7 +342,7 @@ func (s Service) CreateAccount(ctx context.Context, in *proto.CreateAccountReque
indexResults, err := s.index.Add(out)
if err != nil {
s.rollbackCreateAccount(ctx, out)
return merrors.BadRequest(s.id, "Account already exists %v", err.Error())
return merrors.Conflict(s.id, "Account already exists %v", err.Error())
}
s.log.Debug().Interface("account", out).Msg("account after indexing")