Skip to content

Commit

Permalink
Return specific error on dashboard not found during delete
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen committed Nov 27, 2021
1 parent 93ddb0b commit 9d7697c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import (
// ErrFolderNotFound is returned when the given folder can not be found.
var ErrFolderNotFound = errors.New("folder not found")

// ErrDashboardNotFound is returned when the given dashboard can not be found.
var ErrDashboardNotFound = errors.New("dashboard not found")

// ErrAlertChannelNotFound is returned when the given alert notification
// channel can not be found.
var ErrAlertChannelNotFound = errors.New("alert channel not found")
Expand Down Expand Up @@ -252,6 +255,9 @@ func (client *Client) DeleteDashboard(ctx context.Context, uid string) error {

defer func() { _ = resp.Body.Close() }()

if resp.StatusCode == http.StatusNotFound {
return ErrDashboardNotFound
}
if resp.StatusCode != http.StatusOK {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down

0 comments on commit 9d7697c

Please sign in to comment.