Skip to content

Commit

Permalink
[BUG] set cause for already exists EventError (flyteorg#432)
Browse files Browse the repository at this point in the history
* set cause for already exists EventError

Signed-off-by: Paul Dittamo <[email protected]>

* add nil check event error

Signed-off-by: Paul Dittamo <[email protected]>

* lint

Signed-off-by: Paul Dittamo <[email protected]>

---------

Signed-off-by: Paul Dittamo <[email protected]>
  • Loading branch information
pvditt committed Aug 21, 2024
1 parent 73155cd commit 6697ecd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion flytepropeller/events/admin_eventsink.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ func (s *adminEventSink) Sink(ctx context.Context, message proto.Message) error

if s.filter.Contains(ctx, id) {
logger.Debugf(ctx, "event '%s' has already been sent", string(id))
return &errors.EventError{Code: errors.AlreadyExists}
return &errors.EventError{
Code: errors.AlreadyExists,
Cause: fmt.Errorf("event has already been sent"),
Message: "Event Already Exists",
}
}

// Validate submission with rate limiter and send admin event
Expand Down
6 changes: 5 additions & 1 deletion flytepropeller/events/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ type EventError struct {
}

func (r EventError) Error() string {
return fmt.Sprintf("%s: %s, caused by [%s]", r.Code, r.Message, r.Cause.Error())
var cause string
if r.Cause != nil {
cause = r.Cause.Error()
}
return fmt.Sprintf("%s: %s, caused by [%s]", r.Code, r.Message, cause)
}

func (r *EventError) Is(target error) bool {
Expand Down

0 comments on commit 6697ecd

Please sign in to comment.