mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
API: Recognize dashboard errors when saving a folder (#26499)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
4c56eb3991
commit
3a8854b1b9
@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
@ -127,6 +128,11 @@ func toFolderDto(g guardian.DashboardGuardian, folder *models.Folder) dtos.Folde
|
||||
}
|
||||
|
||||
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 ||
|
||||
err == models.ErrFolderSameNameExists ||
|
||||
err == models.ErrFolderWithSameUIDExists ||
|
||||
|
Loading…
Reference in New Issue
Block a user