Commit 3a8854b1 by Arve Knudsen Committed by GitHub

API: Recognize dashboard errors when saving a folder (#26499)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 4c56eb39
package api package api
import ( import (
"errors"
"fmt" "fmt"
"github.com/grafana/grafana/pkg/api/dtos" "github.com/grafana/grafana/pkg/api/dtos"
...@@ -127,6 +128,11 @@ func toFolderDto(g guardian.DashboardGuardian, folder *models.Folder) dtos.Folde ...@@ -127,6 +128,11 @@ func toFolderDto(g guardian.DashboardGuardian, folder *models.Folder) dtos.Folde
} }
func toFolderError(err error) Response { func toFolderError(err error) Response {
var dashboardErr models.DashboardErr
if ok := errors.As(err, &dashboardErr); ok {
return Error(dashboardErr.StatusCode, err.Error(), err)
}
if err == models.ErrFolderTitleEmpty || if err == models.ErrFolderTitleEmpty ||
err == models.ErrFolderSameNameExists || err == models.ErrFolderSameNameExists ||
err == models.ErrFolderWithSameUIDExists || err == models.ErrFolderWithSameUIDExists ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment