2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 23:27:17 +08:00

feat: 优化 shell 执行错误处理

This commit is contained in:
耗子
2023-10-23 21:54:22 +08:00
parent fe66704aaf
commit 9e58b613df

View File

@@ -1,6 +1,7 @@
package tools
import (
"fmt"
"os"
"os/exec"
"path/filepath"
@@ -54,6 +55,8 @@ func Exec(shell string) string {
output, err := cmd.CombinedOutput()
if err != nil {
if support.Env == support.EnvTest {
fmt.Println(string(output))
fmt.Println(err.Error())
panic(err)
} else {
facades.Log().Errorf("[面板][Helpers] 执行命令 %s 失败: %s", shell, err.Error())
@@ -71,6 +74,7 @@ func ExecAsync(shell string) {
err := cmd.Start()
if err != nil {
if support.Env == support.EnvTest {
fmt.Println(err.Error())
panic(err)
} else {
facades.Log().Errorf("[面板][Helpers] 执行命令 %s 失败: %s", shell, err.Error())
@@ -81,6 +85,7 @@ func ExecAsync(shell string) {
err := cmd.Wait()
if err != nil {
if support.Env == support.EnvTest {
fmt.Println(err.Error())
panic(err)
} else {
facades.Log().Errorf("[面板][Helpers] 执行命令 %s 失败: %s", shell, err.Error())