mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
Chore: Enable errorlint linter (#29227)
* Enable errorlint linter * Handle wrapped errors Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
This commit is contained in:
co-authored by
Emil Tullstedt
parent
993adb72e0
commit
9593d57914
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -25,9 +26,8 @@ type GrafanaComClient struct {
|
||||
func (client *GrafanaComClient) GetPlugin(pluginId, repoUrl string) (models.Plugin, error) {
|
||||
logger.Debugf("getting plugin metadata from: %v pluginId: %v \n", repoUrl, pluginId)
|
||||
body, err := sendRequestGetBytes(HttpClient, repoUrl, "repo", pluginId)
|
||||
|
||||
if err != nil {
|
||||
if err == ErrNotFoundError {
|
||||
if errors.Is(err, ErrNotFoundError) {
|
||||
return models.Plugin{}, errutil.Wrap("Failed to find requested plugin, check if the plugin_id is correct", err)
|
||||
}
|
||||
return models.Plugin{}, errutil.Wrap("Failed to send request", err)
|
||||
|
||||
@@ -2,6 +2,7 @@ package services
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@@ -74,8 +75,9 @@ func makeBody(body string) io.ReadCloser {
|
||||
}
|
||||
|
||||
func asBadRequestError(t *testing.T, err error) *BadRequestError {
|
||||
if badRequestError, ok := err.(*BadRequestError); ok {
|
||||
return badRequestError
|
||||
var badErr *BadRequestError
|
||||
if errors.As(err, &badErr) {
|
||||
return badErr
|
||||
}
|
||||
assert.FailNow(t, "Error was not of type BadRequestError")
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user