Return a 404 when deleting a datasource through the API if it doesn't exist and add a test for it to confirm #12313

This commit is contained in:
Austin Winstanley
2018-06-22 21:15:36 -05:00
parent b2187b70a7
commit defb0396b7
2 changed files with 11 additions and 0 deletions
+3
View File
@@ -103,6 +103,9 @@ func DeleteDataSourceByName(c *m.ReqContext) Response {
getCmd := &m.GetDataSourceByNameQuery{Name: name, OrgId: c.OrgId}
if err := bus.Dispatch(getCmd); err != nil {
if err == m.ErrDataSourceNotFound {
return Error(404, "Data source not found", nil)
}
return Error(500, "Failed to delete datasource", err)
}