Skip to content

Commit

Permalink
feat: adds ErrAggregateNotFound error
Browse files Browse the repository at this point in the history
  • Loading branch information
jasseem committed Apr 16, 2024
1 parent 68919b9 commit d9b6f3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package eventsourcing

import "errors"

var (
// ErrAggregateNotFound is returned when an aggregate is not found.
ErrAggregateNotFound = errors.New("aggregate not found")
)
2 changes: 1 addition & 1 deletion pgeventstore/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *storage[S]) Load(ctx context.Context, transaction eventsourcing.Transac
}

if len(events) == 0 {
return nil, errors.New(fmt.Sprintf("aggregate with id '%s' and version '%d' cannot be found", aggregateID, version))
return nil, eventsourcing.ErrAggregateNotFound
}

e := events[0]
Expand Down

0 comments on commit d9b6f3f

Please sign in to comment.