chore: print the original error log in debug mode (#496)
This commit is contained in:
parent
218c1806ff
commit
b17db0f32b
|
|
@ -33,7 +33,6 @@ import (
|
|||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/singleagent"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossworkflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
|
@ -96,14 +95,9 @@ func (r *replyChunkCallback) OnError(ctx context.Context, info *callbacks.RunInf
|
|||
r.sw.Send(interruptEvent, nil)
|
||||
|
||||
} else {
|
||||
logs.CtxErrorf(ctx, "node execute failed, component=%v, name=%v, err=%v",
|
||||
logs.CtxErrorf(ctx, "[AgentRunError] | node execute failed, component=%v, name=%v, err=%v",
|
||||
info.Component, info.Name, err)
|
||||
var customErr errorx.StatusError
|
||||
errMsg := "Internal server error"
|
||||
if errors.As(err, &customErr) && customErr.Code() != 0 {
|
||||
errMsg = customErr.Msg()
|
||||
}
|
||||
r.sw.Send(nil, errors.New(errMsg))
|
||||
r.sw.Send(nil, err)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package consts
|
|||
import "time"
|
||||
|
||||
const (
|
||||
RunMode = "RUN_MODE"
|
||||
MySQLDsn = "MYSQL_DSN"
|
||||
RedisAddr = "REDIS_ADDR"
|
||||
VeImageXAK = "VE_IMAGEX_AK"
|
||||
|
|
|
|||
|
|
@ -33,9 +33,16 @@ const (
|
|||
ErrInterruptDataEmpty = 103100005
|
||||
|
||||
ErrConversationMessageNotFound = 103200001
|
||||
|
||||
ErrAgentRun = 103200002
|
||||
)
|
||||
|
||||
func init() {
|
||||
code.Register(
|
||||
ErrAgentRun,
|
||||
"Interal Server Error",
|
||||
code.WithAffectStability(true),
|
||||
)
|
||||
code.Register(
|
||||
ErrConversationJsonMarshal,
|
||||
"json marshal failed",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# run mode
|
||||
export RUN_MODE="debug" # Currently supports debug mode. When set to debug, it helps developers print raw error messages during development and debugging, such as agent debugging.
|
||||
|
||||
# Server
|
||||
export LISTEN_ADDR=":8888"
|
||||
export LOG_LEVEL="debug"
|
||||
|
|
|
|||
Loading…
Reference in New Issue