chore: print the original error log in debug mode (#496)
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user