Skip to content

Commit

Permalink
Add missing error handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
airenas committed May 30, 2023
1 parent a4a8975 commit 9303e4c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/pkg/mongodb/cmsIntegrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ func (ss *CmsIntegrator) Usage(keyID string, from, to *time.Time, full bool) (*a
res.Logs = append(res.Logs, mapLogRecord(&logR))
}
}
if err := cursor.Err(); err != nil {
return nil, fmt.Errorf("can't get logs: %w", err)
}
return res, err
}

Expand Down Expand Up @@ -340,6 +343,9 @@ func loadKeys(sessCtx mongo.SessionContext, service string, from *time.Time) ([]
}
res = append(res, &keyR)
}
if err := cursor.Err(); err != nil {
return nil, fmt.Errorf("can't get keys: %w", err)
}
return res, nil
}

Expand Down
4 changes: 4 additions & 0 deletions internal/pkg/mongodb/keySaver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mongodb

import (
"context"
"fmt"
"time"

"github.com/airenas/api-doorman/internal/pkg/integration/cms/api"
Expand Down Expand Up @@ -100,6 +101,9 @@ func (ss *KeySaver) List(project string) ([]*adminapi.Key, error) {
}
res = append(res, mapTo(&key))
}
if err := cursor.Err(); err != nil {
return nil, fmt.Errorf("can't get logs: %w", err)
}
return res, nil
}

Expand Down
6 changes: 6 additions & 0 deletions internal/pkg/mongodb/logSaver.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func (ss *LogProvider) Get(project, key string) ([]*adminapi.Log, error) {
}
res = append(res, mapToLog(&logR))
}
if err := cursor.Err(); err != nil {
return nil, fmt.Errorf("can't get logs: %w", err)
}
return res, nil
}

Expand Down Expand Up @@ -111,6 +114,9 @@ func (ss *LogProvider) List(project string, to time.Time) ([]*adminapi.Log, erro
}
res = append(res, mapToLog(&logR))
}
if err := cursor.Err(); err != nil {
return nil, fmt.Errorf("can't get logs: %w", err)
}
return res, nil
}

Expand Down

0 comments on commit 9303e4c

Please sign in to comment.