SDK v3 #8

Merged
SoXX merged 77 commits from dev/issue-5 into main 2024-08-14 13:27:35 +00:00
Showing only changes of commit 6bec8e3373 - Show all commits

View File

@ -3,6 +3,7 @@ package database
import (
"context"
"errors"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/internal/utils"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
@ -32,8 +33,8 @@ func CreateTag(ctx context.Context, tagName models.TagName, tagType models.TagTy
}
logger.WithContext(ctx).WithFields(log.Fields{
"name": tagName,
"type": tagType,
"tag_name": tagName,
"tag_type": tagType,
}).Debug("attempting to create tag")
result := client.WithContext(ctx).Create(&tag)
@ -41,22 +42,22 @@ func CreateTag(ctx context.Context, tagName models.TagName, tagType models.TagTy
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
loggerFields := log.Fields{
"name": tagName,
"type": tagType,
"tag_name": tagName,
"tag_type": tagType,
}
return models.Tag{}, utils.HandleError(ctx, span, logger, loggerFields, &otterError.Database{Reason: otterError.DuplicateKey})
}
loggerFields := log.Fields{
"name": tagName,
"type": tagType,
"tag_name": tagName,
"tag_type": tagType,
}
return models.Tag{}, utils.HandleError(ctx, span, logger, loggerFields, result.Error)
}
logger.WithContext(ctx).WithFields(log.Fields{
"name": tagName,
"type": tagType,
"tag_name": tagName,
"tag_type": tagType,
}).Debug("tag created")
span.AddEvent("Tag created successfully")
return tag, nil