Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions agent/i18n/lang/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SystemRestart: "系统重启导致任务中断"

#backup
ErrBackupInUsed: "该备份账号已在计划任务中使用,无法删除"
ErrBackupCheck: "备份账号测试连接失败 {{ .err}}"
ErrBackupCheck: "备份账号测试连接失败 {{ .err }}"
ErrBackupLocalDelete: "暂不支持删除本地服务器备份账号"
ErrBackupLocalCreate: "暂不支持创建本地服务器备份账号"

Expand All @@ -50,23 +50,23 @@ ErrFileParse: '应用 docker-compose 文件解析失败!'
ErrInstallDirNotFound: '安装目录不存在,如需卸载,请选择强制卸载'
AppStoreIsUpToDate: '应用商店已经是最新版本'
LocalAppVersionNull: '{{.name}} 应用未同步到版本!无法添加到应用列表'
LocalAppVersionErr: '{{.name}} 同步版本 {{.version}} 失败!{{.err}}'
LocalAppVersionErr: '{{.name}} 同步版本 {{.version}} 失败!{{ .err }}'
ErrFileNotFound: '{{.name}} 文件不存在'
ErrFileParseApp: '{{.name}} 文件解析失败 {{.err}}'
ErrFileParseApp: '{{.name}} 文件解析失败 {{ .err }}'
ErrAppDirNull: '版本文件夹不存在'
LocalAppErr: "应用 {{.name}} 同步失败!{{.err}}"
LocalAppErr: "应用 {{.name}} 同步失败!{{ .err }}"
ErrContainerName: "容器名称已存在"
ErrAppSystemRestart: "1Panel 重启导致任务终止"
ErrCreateHttpClient: "创建HTTP请求失败 {{.err}}"
ErrHttpReqTimeOut: "请求超时 {{.err}}"
ErrHttpReqFailed: "请求失败 {{.err}}"
ErrHttpReqNotFound: "文件不存在"
ErrNoSuchHost: "网络连接失败"
ErrCreateHttpClient: "创建请求失败 {{ .err }}"
ErrHttpReqTimeOut: "请求超时 {{ .err }}"
ErrHttpReqFailed: "请求失败 {{ .err }}"
ErrNoSuchHost: "无法找到请求的服务器 {{ .err }}"
ErrHttpReqNotFound: "无法找到请求的资源 {{ .err }}"
ErrImagePullTimeOut: '镜像拉取超时'
ErrContainerNotFound: '{{ .name }} 容器不存在'
ErrContainerMsg: '{{ .name }} 容器异常,具体请在容器页面查看日志'
ErrAppBackup: '{{ .name }} 应用备份失败 err {{.err}}'
ErrImagePull: '镜像拉取失败 {{.err}}'
ErrAppBackup: '{{ .name }} 应用备份失败 err {{ .err }}'
ErrImagePull: '镜像拉取失败 {{ .err }}'
ErrVersionTooLow: '当前 1Panel 版本过低,无法更新应用商店,请升级版本之后操作'
ErrAppNameExist: '应用名称已存在'
AppStoreIsSyncing: '应用商店正在同步中,请稍后再试'
Expand Down Expand Up @@ -100,7 +100,7 @@ ErrPathNotFound: "目录不存在"
ErrMovePathFailed: "目标路径不能包含原路径!"
ErrLinkPathNotFound: "目标路径不存在!"
ErrFileIsExist: "文件或文件夹已存在!"
ErrFileUpload: "{{ .name }} 上传文件失败 {{ .detail}}"
ErrFileUpload: "{{ .name }} 上传文件失败 {{ .detail }}"
ErrFileDownloadDir: "不支持下载文件夹"
ErrCmdNotFound: "{{ .name}} 命令不存在,请先在宿主机安装此命令"
ErrSourcePathNotFound: "源目录不存在"
Expand All @@ -112,8 +112,8 @@ ErrPathNotDelete: "所选目录不可删除"
ErrDomainIsExist: "域名已存在"
ErrAliasIsExist: "代号已存在"
ErrAppDelete: '其他网站使用此应用,无法删除'
ErrBackupMatch: '该备份文件与当前网站部分数据不匹配 {{ .detail}}'
ErrBackupExist: '该备份文件对应部分源数据不存在 {{ .detail}}'
ErrBackupMatch: '该备份文件与当前网站部分数据不匹配 {{ .detail }}'
ErrBackupExist: '该备份文件对应部分源数据不存在 {{ .detail }}'
ErrPHPResource: '本地运行环境不支持切换!'
ErrPathPermission: 'index 目录下检测到非 1000:1000 权限文件夹,可能导致网站访问 Access denied 错误,请点击上方保存按钮'
ErrDomainIsUsed: "域名已被网站【{{ .name }}】使用"
Expand Down Expand Up @@ -290,7 +290,7 @@ InstallAppSuccess: "应用 {{ .name }} 安装成功"
ConfigRuntime: "配置运行环境"
ConfigApp: "配置应用"
SuccessStatus: "{{ .name }} 成功"
FailedStatus: "{{ .name }} 失败 {{.err}}"
FailedStatus: "{{ .name }} 失败 {{ .err }}"
HandleLink: "处理应用关联"
HandleDatabaseApp: "处理应用参数"
ExecShell: "执行 {{ .name }} 脚本"
Expand Down
4 changes: 4 additions & 0 deletions core/app/api/v2/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ func ErrorWithDetail(ctx *gin.Context, code int, msgKey string, err error) {
Code: code,
Message: "",
}
if msgKey == "ErrCaptchaCode" || msgKey == "ErrAuth" {
res.Code = 406
res.Message = msgKey
}
res.Message = i18n.GetMsgWithMap(msgKey, map[string]interface{}{"detail": err})
ctx.JSON(http.StatusOK, res)
ctx.Abort()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot determine the specific difference or issue without reviewing all of your submitted code. However, I can suggest that you double-check if there's an inconsistency between message translation keys (msgKey) and messages being constructed (res.Message). Additionally, ensure consistency across different parts of your program (e.g., functions within ErrorWithDetails).

Expand Down
19 changes: 10 additions & 9 deletions core/i18n/lang/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ ErrApiConfigIPInvalid: "调用 API 接口 IP 不在白名单: {{ .detail }}"
ErrApiConfigDisable: "此接口禁止使用 API 接口调用: {{ .detail }}"
ErrApiConfigKeyTimeInvalid: "API 接口时间戳错误: {{ .detail }}"

#request
ErrNoSuchHost: "无法找到请求的服务器 {{ .err }}"
ErrHttpReqNotFound: "无法找到请求的资源 {{ .err }}"
ErrHttpReqFailed: "请求失败 {{ .err }}"
ErrHttpReqTimeOut: "请求超时 {{ .err }}"
ErrCreateHttpClient: "创建请求失败 {{ .err }}"

#common
ErrDemoEnvironment: "演示服务器,禁止此操作!"
ErrCmdTimeout: "命令执行超时!"
Expand All @@ -23,6 +30,9 @@ ErrGroupIsDefault: "默认分组,无法删除"
ErrLocalDelete: "无法删除本地节点!"
ErrPortInUsed: "{{ .name }} 端口已被占用!"

#app
CustomAppStoreFileValid: "应用商店包需要 .tar.gz 格式"

#backup
ErrBackupInUsed: "该备份账号已在计划任务中使用,无法删除"
ErrBackupCheck: "备份账号测试连接失败 {{ .err }}"
Expand Down Expand Up @@ -61,19 +71,10 @@ TaskRetry: "开始第 {{ .name }} 次重试"
SubTaskSuccess: "{{ .name }} 成功"
SubTaskFailed: "{{ .name }} 失败: {{ .err }}"
TaskInstall: "安装"
TaskUninstall: "卸载"
TaskCreate: "创建"
TaskDelete: "删除"
TaskUpgrade: "升级"
TaskUpdate: "更新"
TaskRestart: "重启"
TaskRollback: "回滚"
SuccessStatus: "{{ .name }} 成功"
FailedStatus: "{{ .name }} 失败 {{.err}}"
PullImage: "拉取镜像"
Start: "开始"
Run: "启动"
Stop: "停止"
SubTask: "子任务"

#upgrade node
Expand Down
4 changes: 2 additions & 2 deletions core/utils/req_helper/requset.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ func handleGetWithTransport(url string, transport *http.Transport) (*http.Respon
return nil, buserr.WithMap("ErrHttpReqTimeOut", map[string]interface{}{"err": err.Error()}, err)
} else {
if strings.Contains(err.Error(), "no such host") {
return nil, buserr.New("ErrNoSuchHost")
return nil, buserr.WithErr("ErrNoSuchHost", errors.New("no such host"))
}
return nil, buserr.WithMap("ErrHttpReqFailed", map[string]interface{}{"err": err.Error()}, err)
}
}
if resp.StatusCode == 404 {
return nil, buserr.New("ErrHttpReqNotFound")
return nil, buserr.WithErr("ErrHttpReqNotFound", errors.New("no such resource"))
}

return resp, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has no known irregularities. No issues or optimization suggestions were indicated during analysis of the given code snippet related to HTTP GET requests handling with timeouts using Go programming language (which is based on OpenAI's knowledge). This code snippet appears correct according to its current use case and does not require further modifications.

However, if you are looking at other aspects like concurrency controls or performance optimizations without changing core functionality:

For concurrency control purposes within goroutines, checking for context cancellation can help avoid unnecessary network calls in error recovery scenarios.

Also look into more efficient timeouts than the provided example, such as custom timeouts defined within transport struct fields, which allow managing request times faster by adjusting their settings dynamically rather than having them hard-coded everywhere (defaultMaxIdleConnsPerHost).

Regarding performance improvements, consider adding additional checks after timeouts to ensure they're due to timeout conditions; these could be non-existent, unexpected behavior, or server configuration changes that have no effect when expected.

Note that while this code doesn't exhibit any obvious problems, it might benefit from careful review considering its broader function scope and how it interacts with the rest of system infrastructure including error contexts or response processing logic within handlers, services etc.

Expand Down
Loading