chore: improve logging for creating a new remote (#360)

* chore: improve logging for creating a new remote

* chore: improve error logging for creating remote
This commit is contained in:
Dane Strandboge
2022-02-04 14:06:35 -06:00
committed by GitHub
parent 9ddf110ad6
commit 041ebf65e3

View File

@ -29,7 +29,13 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
orgID, err := params.GetOrgID(ctx, c.ActiveConfig, c.OrganizationsApi)
if err != nil {
return err
return fmt.Errorf("failed to find local org id: %w", err)
}
// Test that the local org can be properly found for better error displaying
_, err = c.OrganizationsApi.GetOrgs(ctx).OrgID(orgID).Execute()
if err != nil {
return fmt.Errorf("failed to lookup local org: %w", err)
}
// set up a struct with required params
@ -49,7 +55,7 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
// send post request
res, err := c.PostRemoteConnection(ctx).RemoteConnectionCreationRequest(body).Execute()
if err != nil {
return fmt.Errorf("failed to create remote connection %q: %w", params.Name, err)
return fmt.Errorf("failed to create remote connection %q in local InfluxDB: %w", params.Name, err)
}
// print confirmation of new connection