Azure Monitor: Set error source in http and user errors accordingly (#100873)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package azmoncredentials
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/grafana/grafana-azure-sdk-go/v2/azcredentials"
|
||||
"github.com/grafana/grafana-azure-sdk-go/v2/azsettings"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data/utils/maputil"
|
||||
)
|
||||
|
||||
@@ -95,7 +97,7 @@ func getFromLegacy(data map[string]interface{}, secureData map[string]string) (a
|
||||
clientSecret := secureData["clientSecret"]
|
||||
|
||||
if secureData["clientSecret"] == "" {
|
||||
return nil, fmt.Errorf("unable to instantiate credentials, clientSecret must be set")
|
||||
return nil, backend.DownstreamError(errors.New("unable to instantiate credentials, clientSecret must be set"))
|
||||
}
|
||||
|
||||
credentials := &azcredentials.AzureClientSecretCredentials{
|
||||
|
||||
@@ -269,7 +269,11 @@ func (e *AzureMonitorDatasource) retrieveSubscriptionDetails(cli *http.Client, c
|
||||
|
||||
res, err := cli.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to request subscription details: %s", err)
|
||||
err = fmt.Errorf("failed to request subscription details: %s", err)
|
||||
if backend.IsDownstreamHTTPError(err) {
|
||||
err = backend.DownstreamError(err)
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
|
||||
Reference in New Issue
Block a user