Skip to content

Commit

Permalink
generic.go: GenericContainer(): clearer error message (#2327)
Browse files Browse the repository at this point in the history
It's customary to prefix an actual Go error with a generic message explaining the error context.

Ir looks like it's already done this way everywhere [1] else in the code base, but not here.

[1] https://github.com/search?q=repo%3Atestcontainers%2Ftestcontainers-go%20%22failed%20to%20start%20container%22&type=code
  • Loading branch information
JordanP committed Mar 6, 2024
1 parent cfd60e9 commit 12f23f8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func Test_GetLogsFromFailedContainer(t *testing.T) {
Started: true,
})

if err != nil && err.Error() != "container exited with code 0: failed to start container" {
if err != nil && err.Error() != "failed to start container: container exited with code 0" {
t.Fatal(err)
} else if err == nil {
terminateContainerOnEnd(t, ctx, c)
Expand Down
2 changes: 1 addition & 1 deletion generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func GenericContainer(ctx context.Context, req GenericContainerRequest) (Contain

if req.Started && !c.IsRunning() {
if err := c.Start(ctx); err != nil {
return c, fmt.Errorf("%w: failed to start container", err)
return c, fmt.Errorf("failed to start container: %w", err)
}
}
return c, nil
Expand Down

0 comments on commit 12f23f8

Please sign in to comment.