feedback error handling
This commit is contained in:
@@ -2,6 +2,7 @@ package feedback
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
"tm/pkg/logger"
|
||||
orm "tm/pkg/mongo"
|
||||
@@ -113,6 +114,9 @@ func (r *feedbackRepository) Update(ctx context.Context, feedback *Feedback) err
|
||||
func (r *feedbackRepository) GetByID(ctx context.Context, id string) (*Feedback, error) {
|
||||
feedback, err := r.repo.FindByID(ctx, id)
|
||||
if err != nil {
|
||||
if errors.Is(err, orm.ErrDocumentNotFound) {
|
||||
return nil, ErrFeedbackNotFound
|
||||
}
|
||||
r.logger.Error("Failed to get feedback by ID", map[string]interface{}{
|
||||
"feedback_id": id,
|
||||
"error": err.Error(),
|
||||
@@ -129,6 +133,9 @@ func (r *feedbackRepository) GetByCompanyID(ctx context.Context, companyID strin
|
||||
|
||||
result, err := r.repo.FindOne(ctx, filter)
|
||||
if err != nil {
|
||||
if errors.Is(err, orm.ErrDocumentNotFound) {
|
||||
return nil, ErrFeedbackNotFound
|
||||
}
|
||||
r.logger.Error("Failed to get feedback by company ID and tender ID", map[string]interface{}{
|
||||
"company_id": companyID,
|
||||
"tender_id": tenderID,
|
||||
@@ -146,6 +153,9 @@ func (r *feedbackRepository) GetByTenderID(ctx context.Context, tenderID, compan
|
||||
|
||||
result, err := r.repo.FindOne(ctx, filter)
|
||||
if err != nil {
|
||||
if errors.Is(err, orm.ErrDocumentNotFound) {
|
||||
return nil, ErrFeedbackNotFound
|
||||
}
|
||||
r.logger.Error("Failed to get feedback by tender ID and company ID", map[string]interface{}{
|
||||
"tender_id": tenderID,
|
||||
"company_id": companyID,
|
||||
|
||||
Reference in New Issue
Block a user