mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
improved error handling
This commit is contained in:
@@ -24,6 +24,8 @@ import (
|
|||||||
"github.com/cyphar/filepath-securejoin"
|
"github.com/cyphar/filepath-securejoin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const signalCliV2GroupError = "Cannot create a V2 group as self does not have a versioned profile"
|
||||||
|
|
||||||
const groupPrefix = "group."
|
const groupPrefix = "group."
|
||||||
|
|
||||||
type GroupEntry struct {
|
type GroupEntry struct {
|
||||||
@@ -178,7 +180,11 @@ func send(c *gin.Context, attachmentTmpDir string, signalCliConfig string, numbe
|
|||||||
_, err := runSignalCli(true, cmd, message)
|
_, err := runSignalCli(true, cmd, message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cleanupTmpFiles(attachmentTmpPaths)
|
cleanupTmpFiles(attachmentTmpPaths)
|
||||||
c.JSON(400, gin.H{"error": err.Error()})
|
if strings.Contains(err.Error(), signalCliV2GroupError) {
|
||||||
|
c.JSON(400, Error{Msg: "Cannot create group - please first update your profile."})
|
||||||
|
} else {
|
||||||
|
c.JSON(400, Error{Msg: err.Error()})
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,7 +574,11 @@ func (a *Api) CreateGroup(c *gin.Context) {
|
|||||||
|
|
||||||
out, err := runSignalCli(true, cmd, "")
|
out, err := runSignalCli(true, cmd, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, gin.H{"error": err.Error()})
|
if strings.Contains(err.Error(), signalCliV2GroupError) {
|
||||||
|
c.JSON(400, Error{Msg: "Cannot create group - please first update your profile."})
|
||||||
|
} else {
|
||||||
|
c.JSON(400, Error{Msg: err.Error()})
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user