Skip to content

Commit a195016

Browse files
Better error handling for empty server responses (#1741)
1 parent b1e41f5 commit a195016

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

observability-lib/grafana/datasource.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package grafana
22

3-
import "github.com/smartcontractkit/chainlink-common/observability-lib/api"
3+
import (
4+
"errors"
5+
6+
"github.com/smartcontractkit/chainlink-common/observability-lib/api"
7+
)
48

59
type DataSource struct {
610
ID uint
@@ -26,6 +30,9 @@ func GetDataSourceFromGrafana(name string, grafanaURL string, grafanaToken strin
2630
if err != nil {
2731
return nil, err
2832
}
33+
if datasource.Name == "" {
34+
return nil, errors.New("unexpected empty response. please check connection or vpn settings")
35+
}
2936

3037
return &DataSource{ID: datasource.ID, Name: datasource.Name, UID: datasource.UID, Type: datasource.Type}, nil
3138
}

0 commit comments

Comments
 (0)