feat(error): more error handling
added missing checks
This commit is contained in:
parent
a9ac2a34fb
commit
5562d75e3a
@ -32,6 +32,14 @@ func CreateTagAlias(ctx context.Context, tagAliasName models.TagAliasName, tagNa
|
||||
return models.TagAlias{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
|
||||
}
|
||||
|
||||
if tagAliasName == "" {
|
||||
return models.TagAlias{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.TagAliasNameIsEmpty})
|
||||
}
|
||||
|
||||
if tagName == "" {
|
||||
return models.TagAlias{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.TagNameIsEmpty})
|
||||
}
|
||||
|
||||
tagAlias := models.TagAlias{
|
||||
Name: tagAliasName,
|
||||
TagID: tagName,
|
||||
@ -109,6 +117,10 @@ func DeleteTagAlias(ctx context.Context, tagAliasName models.TagAliasName) error
|
||||
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
|
||||
}
|
||||
|
||||
if len(tagAliasName) == 0 {
|
||||
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.TagAliasNameIsEmpty})
|
||||
}
|
||||
|
||||
result := client.WithContext(ctx).Delete(&tagAlias, tagAliasName)
|
||||
if result.Error != nil {
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
|
Loading…
Reference in New Issue
Block a user