Skip to content

Commit

Permalink
give additional context if there's an error
Browse files Browse the repository at this point in the history
  • Loading branch information
raulb committed Jan 16, 2025
1 parent d6f29b1 commit c2e2eb2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/conduit/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,20 @@ func NewClient(ctx context.Context, address string) (*Client, error) {
HealthClient: healthgrpc.NewHealthClient(conn),
}

if err := client.CheckHealth(ctx); err != nil {
if err := client.CheckHealth(ctx, address); err != nil {
client.Close()
return nil, err
}

return client, nil
}

func (c *Client) CheckHealth(ctx context.Context) error {
func (c *Client) CheckHealth(ctx context.Context, address string) error {
healthResp, err := c.HealthClient.Check(ctx, &healthgrpc.HealthCheckRequest{})
if err != nil || healthResp.Status != healthgrpc.HealthCheckResponse_SERVING {
return fmt.Errorf("notice: to inspect the API, Conduit needs to be running\nPlease execute `conduit run`")
return fmt.Errorf("We couldn't connect to Conduit at the configured address %q\n"+

Check failure on line 59 in cmd/conduit/api/client.go

View workflow job for this annotation

GitHub Actions / golangci-lint

ST1005: error strings should not be capitalized (stylecheck)
"Please execute `conduit run` to start it.\nTo check the current configured `api.grpc.address`, run `conduit config`\n\n"+
"Error details: %v", address, err)
}
return nil
}
Expand Down

0 comments on commit c2e2eb2

Please sign in to comment.