Return error as string

This commit is contained in:
rxdn 2022-06-01 18:00:51 +01:00
parent e0ada652d4
commit 0566d2498f
3 changed files with 13 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
dbclient "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/rpc/cache"
"github.com/TicketsBot/GoPanel/utils"
"github.com/TicketsBot/database"
"github.com/gin-gonic/gin"
"github.com/rxdn/gdl/objects/channel"
@ -27,7 +28,11 @@ func UpdateSettingsHandler(ctx *gin.Context) {
channels := cache.Instance.GetGuildChannels(guildId)
// TODO: Errors
err := settings.updateSettings(guildId)
var errStr *string = nil
if e := settings.updateSettings(guildId); e != nil {
errStr = utils.Ptr(e.Error())
}
validPrefix := settings.updatePrefix(guildId)
validWelcomeMessage := settings.updateWelcomeMessage(guildId)
validTicketLimit := settings.updateTicketLimit(guildId)
@ -46,7 +51,7 @@ func UpdateSettingsHandler(ctx *gin.Context) {
"archive_channel": validArchiveChannel,
"category": validCategory,
"naming_scheme": validNamingScheme,
"error": err,
"error": errStr,
})
}

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/TicketsBot/GoPanel
go 1.14
go 1.18
require (
github.com/BurntSushi/toml v0.3.1

5
utils/utils.go Normal file
View File

@ -0,0 +1,5 @@
package utils
func Ptr[T any](v T) *T {
return &v
}