feat(api): fixed minor issue with error message when trying to create duplicate datasource, fixes #6164

This commit is contained in:
Torkel Ödegaard
2016-10-01 16:41:27 +02:00
parent 4f2263552c
commit a6918617ff
3 changed files with 15 additions and 1 deletions

View File

@ -92,6 +92,11 @@ func AddDataSource(c *middleware.Context, cmd m.AddDataSourceCommand) {
cmd.OrgId = c.OrgId
if err := bus.Dispatch(&cmd); err != nil {
if err == m.ErrDataSourceNameExists {
c.JsonApiErr(409, err.Error(), err)
return
}
c.JsonApiErr(500, "Failed to add datasource", err)
return
}