Skip to content

Commit

Permalink
chore: update constructor name (#1817)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulb authored Aug 30, 2024
1 parent bab1afb commit 54bf050
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/foundation/cerrors/fatal.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type fatalError struct {
Err error
}

// NewFatalError creates a new fatalError.
func NewFatalError(err error) *fatalError {
// FatalError creates a new fatalError.
func FatalError(err error) *fatalError {
return &fatalError{Err: err}
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/foundation/cerrors/fatal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestNewFatalError(t *testing.T) {
is := is.New(t)

err := cerrors.New("test error")
fatalErr := cerrors.NewFatalError(err)
fatalErr := cerrors.FatalError(err)
wantErr := fmt.Sprintf("fatal error: %v", err)

is.Equal(fatalErr.Error(), wantErr)
Expand All @@ -43,12 +43,12 @@ func TestIsFatalError(t *testing.T) {
}{
{
name: "when it's a fatalError",
err: cerrors.NewFatalError(err),
err: cerrors.FatalError(err),
want: true,
},
{
name: "when it's wrapped in",
err: fmt.Errorf("something went wrong: %w", cerrors.NewFatalError(cerrors.New("fatal error"))),
err: fmt.Errorf("something went wrong: %w", cerrors.FatalError(cerrors.New("fatal error"))),
want: true,
},
{
Expand All @@ -70,7 +70,7 @@ func TestUnwrap(t *testing.T) {
is := is.New(t)

err := cerrors.New("test error")
fatalErr := cerrors.NewFatalError(err)
fatalErr := cerrors.FatalError(err)

is.Equal(cerrors.Unwrap(fatalErr), err)
}
Expand All @@ -79,7 +79,7 @@ func TestFatalError(t *testing.T) {
is := is.New(t)

err := cerrors.New("test error")
fatalErr := cerrors.NewFatalError(err)
fatalErr := cerrors.FatalError(err)
wantErr := fmt.Sprintf("fatal error: %v", err)

is.Equal(fatalErr.Error(), wantErr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/stream/dlq.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (n *DLQHandlerNode) Nack(msg *Message, nackMetadata NackMetadata) (err erro

ok := n.window.Nack()
if !ok {
return cerrors.NewFatalError(cerrors.Errorf(
return cerrors.FatalError(cerrors.Errorf(
"DLQ nack threshold exceeded (%d/%d), original error: %w",
n.WindowNackThreshold, n.WindowSize, nackMetadata.Reason,
))
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/stream/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (n *ProcessorNode) Run(ctx context.Context) error {
case sdk.ErrorRecord:
err = msg.Nack(v.Error, n.ID())
if err != nil {
return cerrors.NewFatalError(cerrors.Errorf("error executing processor: %w", err))
return cerrors.FatalError(cerrors.Errorf("error executing processor: %w", err))
}
}
}
Expand Down

0 comments on commit 54bf050

Please sign in to comment.