humanise: update error list and move generator
This commit is contained in:
Generated
+9
-1
@@ -74,6 +74,8 @@ func Error(err error) string {
|
||||
return "The command description was empty, too long or had invalid characters used"
|
||||
case tgerr.Is(err, "BOT_COMMAND_INVALID"):
|
||||
return "The specified command is invalid"
|
||||
case tgerr.Is(err, "BOT_COMMANDS_TOO_MUCH"):
|
||||
return "The provided commands are too many"
|
||||
case tgerr.Is(err, "BOT_DOMAIN_INVALID"):
|
||||
return "The domain used for the auth button does not match the one configured in @BotFather"
|
||||
case tgerr.Is(err, "BOT_GAMES_DISABLED"):
|
||||
@@ -364,6 +366,8 @@ func Error(err error) string {
|
||||
return "A wait of {seconds} seconds is required in the test servers"
|
||||
case tgerr.Is(err, "FLOOD_WAIT_X"):
|
||||
return "A wait of {seconds} seconds is required"
|
||||
case tgerr.Is(err, "FLOOD_PREMIUM_WAIT_X"):
|
||||
return "A wait of {seconds} seconds is required in non-premium accounts"
|
||||
case tgerr.Is(err, "FOLDER_ID_EMPTY"):
|
||||
return "The folder you tried to delete was already empty"
|
||||
case tgerr.Is(err, "FOLDER_ID_INVALID"):
|
||||
@@ -531,7 +535,7 @@ func Error(err error) string {
|
||||
case tgerr.Is(err, "MESSAGE_POLL_CLOSED"):
|
||||
return "The poll was closed and can no longer be voted on"
|
||||
case tgerr.Is(err, "MESSAGE_TOO_LONG"):
|
||||
return "Message was too long. Current maximum length is 4096 UTF-8 characters"
|
||||
return "Message was too long"
|
||||
case tgerr.Is(err, "METHOD_INVALID"):
|
||||
return "The API method is invalid and cannot be used"
|
||||
case tgerr.Is(err, "MIN_DATE_INVALID"):
|
||||
@@ -1054,6 +1058,10 @@ func Error(err error) string {
|
||||
return "Telegram workers are too busy to respond immediately"
|
||||
case tgerr.Is(err, "YOU_BLOCKED_USER"):
|
||||
return "You blocked this user"
|
||||
case tgerr.Is(err, "FROZEN_METHOD_INVALID"):
|
||||
return "You tried to use a method that is not available for frozen accounts"
|
||||
case tgerr.Is(err, "FROZEN_PARTICIPANT_MISSING"):
|
||||
return "Your account is frozen and can't access the chat"
|
||||
}
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ BOTS_TOO_MUCH,400,There are too many bots in this chat/channel
|
||||
BOT_CHANNELS_NA,400,Bots can't edit admin privileges
|
||||
BOT_COMMAND_DESCRIPTION_INVALID,400,"The command description was empty, too long or had invalid characters used"
|
||||
BOT_COMMAND_INVALID,400,The specified command is invalid
|
||||
BOT_COMMANDS_TOO_MUCH,400,"The provided commands are too many"
|
||||
BOT_DOMAIN_INVALID,400,The domain used for the auth button does not match the one configured in @BotFather
|
||||
BOT_GAMES_DISABLED,400,Bot games cannot be used in this type of chat
|
||||
BOT_GROUPS_BLOCKED,400,This bot can't be added to groups
|
||||
@@ -178,6 +179,7 @@ FILTER_TITLE_EMPTY,400,The title field of the filter is empty
|
||||
FIRSTNAME_INVALID,400,The first name is invalid
|
||||
FLOOD_TEST_PHONE_WAIT_X,420,A wait of {seconds} seconds is required in the test servers
|
||||
FLOOD_WAIT_X,420,A wait of {seconds} seconds is required
|
||||
FLOOD_PREMIUM_WAIT_X,420,A wait of {seconds} seconds is required in non-premium accounts
|
||||
FOLDER_ID_EMPTY,400,The folder you tried to delete was already empty
|
||||
FOLDER_ID_INVALID,400,The folder you tried to use was not valid
|
||||
FRESH_CHANGE_ADMINS_FORBIDDEN,400 406,Recently logged-in users cannot add or change admins
|
||||
@@ -261,7 +263,7 @@ MESSAGE_IDS_EMPTY,400,No message ids were provided
|
||||
MESSAGE_ID_INVALID,400,The specified message ID is invalid or you can't do that operation on such message
|
||||
MESSAGE_NOT_MODIFIED,400,Content of the message was not modified
|
||||
MESSAGE_POLL_CLOSED,400,The poll was closed and can no longer be voted on
|
||||
MESSAGE_TOO_LONG,400,Message was too long. Current maximum length is 4096 UTF-8 characters
|
||||
MESSAGE_TOO_LONG,400,Message was too long
|
||||
METHOD_INVALID,400,The API method is invalid and cannot be used
|
||||
MIN_DATE_INVALID,400,The specified minimum date is invalid
|
||||
MSGID_DECREASE_RETRY,500,The request should be retried with a lower message ID
|
||||
@@ -523,3 +525,5 @@ WEBPUSH_KEY_INVALID,400,The specified web push elliptic curve Diffie-Hellman pub
|
||||
WEBPUSH_TOKEN_INVALID,400,The specified web push token is invalid
|
||||
WORKER_BUSY_TOO_LONG_RETRY,500,Telegram workers are too busy to respond immediately
|
||||
YOU_BLOCKED_USER,400,You blocked this user
|
||||
FROZEN_METHOD_INVALID,420,You tried to use a method that is not available for frozen accounts
|
||||
FROZEN_PARTICIPANT_MISSING,400,Your account is frozen and can't access the chat
|
||||
|
@@ -28,9 +28,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
currentDir := exerrors.Must(os.Getwd())
|
||||
|
||||
errorCSV := exerrors.Must(os.Open(currentDir + "/../../internal/gen/errors.csv"))
|
||||
errorCSV := exerrors.Must(os.Open("gen/errors.csv"))
|
||||
reader := csv.NewReader(errorCSV)
|
||||
var data bytes.Buffer
|
||||
data.WriteString("package humanise\n")
|
||||
@@ -62,5 +60,5 @@ func main() {
|
||||
data.WriteString("return err.Error()")
|
||||
data.WriteString("}")
|
||||
|
||||
exerrors.PanicIfNotNil(os.WriteFile(currentDir+"/errors.go", data.Bytes(), os.ModePerm))
|
||||
exerrors.PanicIfNotNil(os.WriteFile("errors.go", data.Bytes(), os.ModePerm))
|
||||
}
|
||||
@@ -17,5 +17,5 @@
|
||||
// Package humanise turns things into human-readable strings.
|
||||
package humanise
|
||||
|
||||
//go:generate go run ../../internal/gen
|
||||
//go:generate go run ./gen
|
||||
//go:generate goimports -w errors.go
|
||||
|
||||
Reference in New Issue
Block a user