chore: print the original error log in debug mode (#496)

This commit is contained in:
junwen-lee
2025-08-06 10:17:19 +08:00
committed by GitHub
parent 218c1806ff
commit b17db0f32b
5 changed files with 28 additions and 10 deletions

View File

@@ -23,8 +23,10 @@ import (
"errors"
"fmt"
"io"
"os"
"runtime/debug"
"strconv"
"strings"
"sync"
"time"
@@ -47,6 +49,7 @@ import (
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/logs"
"github.com/coze-dev/coze-studio/backend/pkg/safego"
"github.com/coze-dev/coze-studio/backend/types/consts"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
@@ -714,9 +717,19 @@ func (c *runImpl) handlerUsage(meta *schema.ResponseMeta) *msgEntity.UsageExt {
}
func (c *runImpl) handlerErr(_ context.Context, err error, sw *schema.StreamWriter[*entity.AgentRunResponse]) {
errMsg := errorx.ErrorWithoutStack(err)
if strings.ToLower(os.Getenv(consts.RunMode)) != "debug" {
var statusErr errorx.StatusError
if errors.As(err, &statusErr) {
errMsg = statusErr.Msg()
} else {
errMsg = "Internal Server Error"
}
}
c.runEvent.SendErrEvent(entity.RunEventError, sw, &entity.RunError{
Code: errno.ErrConversationAgentRunError,
Msg: errorx.ErrorWithoutStack(err),
Code: errno.ErrAgentRun,
Msg: errMsg,
})
}