Files
mp-qvyun/pkg/wechat/errors.go
2024-11-27 11:55:09 +08:00

34 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package wechat
import "github.com/pkg/errors"
// -1 系统繁忙,此时请开发者稍候再试
// 0 请求成功
// 40001 AppSecret错误或者AppSecret不属于这个公众号请开发者确认AppSecret的正确性
// 40002 请确保grant_type字段值为client_credential
// 40164 调用接口的IP地址不在白名单中请在接口IP白名单中进行设置。
// 40243 AppSecret已被冻结请登录MP解冻后再次调用。
// 89503 此IP调用需要管理员确认,请联系管理员
// 89501 此IP正在等待管理员确认,请联系管理员
// 89506 24小时内该IP被管理员拒绝调用两次24小时内不可再使用该IP调用
// 89507 1小时内该IP被管理员拒绝调用一次1小时内不可再使用该IP调用
func translateError(errCode int) error {
errors := map[int]error{
0: nil,
-1: errors.New("系统繁忙,此时请开发者稍候再试"),
40001: errors.New("AppSecret错误或者AppSecret不属于这个公众号请开发者确认AppSecret的正确性"),
40002: errors.New("请确保grant_type字段值为client_credential"),
40164: errors.New("调用接口的IP地址不在白名单中请在接口IP白名单中进行设置"),
40243: errors.New("AppSecret已被冻结请登录MP解冻后再次调用"),
89503: errors.New("此IP调用需要管理员确认,请联系管理员"),
89501: errors.New("此IP正在等待管理员确认,请联系管理员"),
89506: errors.New("24小时内该IP被管理员拒绝调用两次24小时内不可再使用该IP调用"),
89507: errors.New("1小时内该IP被管理员拒绝调用一次1小时内不可再使用该IP调用"),
}
if err, ok := errors[errCode]; ok {
return err
}
return nil
}