diff --git a/internal/api/http/handlers/target/target.go b/internal/api/http/handlers/target/target.go index 64ad184..a788a4d 100644 --- a/internal/api/http/handlers/target/target.go +++ b/internal/api/http/handlers/target/target.go @@ -62,6 +62,11 @@ func GetAllTarget(targetService model.TargetService) echo.HandlerFunc { return request.JSON(http.StatusInternalServerError, err.Error()) } + if len(targets) == 0 { + slog.Error("target not found") + return request.JSON(http.StatusInternalServerError, "target not found") + } + return request.JSON(http.StatusOK, targets) } } diff --git a/internal/repository/target/target.go b/internal/repository/target/target.go index 2a35314..c0efd5c 100644 --- a/internal/repository/target/target.go +++ b/internal/repository/target/target.go @@ -4,7 +4,6 @@ import ( "context" "donat-widget/internal/model" "donat-widget/internal/model/sql" - "errors" "github.com/georgysavva/scany/v2/pgxscan" "github.com/jackc/pgx/v5" "log/slog" @@ -59,9 +58,6 @@ func (targetRepo *RepoTarget) GetAllTarget( slog.Error(err.Error()) return nil, err } - if len(targets) == 0 { - return nil, errors.New("donat not found") - } return targets, nil