Changeset 0.17.1 (#76)
This commit is contained in:
@@ -3,10 +3,10 @@ package handlers
|
||||
import (
|
||||
"database/sql"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.gobha.me/xcaliber/chat-switchboard/database"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/models"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/store"
|
||||
)
|
||||
@@ -88,7 +88,7 @@ func (h *GroupHandler) CreateGroup(c *gin.Context) {
|
||||
}
|
||||
|
||||
if err := h.stores.Groups.Create(c.Request.Context(), g); err != nil {
|
||||
if strings.Contains(err.Error(), "duplicate key") {
|
||||
if database.IsUniqueViolation(err) {
|
||||
c.JSON(http.StatusConflict, gin.H{"error": "group name already exists in this scope"})
|
||||
return
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func (h *GroupHandler) UpdateGroup(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "duplicate key") {
|
||||
if database.IsUniqueViolation(err) {
|
||||
c.JSON(http.StatusConflict, gin.H{"error": "group name already exists in this scope"})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user