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/api/model/crossdomain/singleagent"
|
||||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossworkflow"
|
"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/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/lang/conv"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
"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)
|
r.sw.Send(interruptEvent, nil)
|
||||||
|
|
||||||
} else {
|
} 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)
|
info.Component, info.Name, err)
|
||||||
var customErr errorx.StatusError
|
r.sw.Send(nil, err)
|
||||||
errMsg := "Internal server error"
|
|
||||||
if errors.As(err, &customErr) && customErr.Code() != 0 {
|
|
||||||
errMsg = customErr.Msg()
|
|
||||||
}
|
|
||||||
r.sw.Send(nil, errors.New(errMsg))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,10 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -47,6 +49,7 @@ import (
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
"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/logs"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/safego"
|
"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"
|
"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]) {
|
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{
|
c.runEvent.SendErrEvent(entity.RunEventError, sw, &entity.RunError{
|
||||||
Code: errno.ErrConversationAgentRunError,
|
Code: errno.ErrAgentRun,
|
||||||
Msg: errorx.ErrorWithoutStack(err),
|
Msg: errMsg,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package consts
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
RunMode = "RUN_MODE"
|
||||||
MySQLDsn = "MYSQL_DSN"
|
MySQLDsn = "MYSQL_DSN"
|
||||||
RedisAddr = "REDIS_ADDR"
|
RedisAddr = "REDIS_ADDR"
|
||||||
VeImageXAK = "VE_IMAGEX_AK"
|
VeImageXAK = "VE_IMAGEX_AK"
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,16 @@ const (
|
||||||
ErrInterruptDataEmpty = 103100005
|
ErrInterruptDataEmpty = 103100005
|
||||||
|
|
||||||
ErrConversationMessageNotFound = 103200001
|
ErrConversationMessageNotFound = 103200001
|
||||||
|
|
||||||
|
ErrAgentRun = 103200002
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
code.Register(
|
||||||
|
ErrAgentRun,
|
||||||
|
"Interal Server Error",
|
||||||
|
code.WithAffectStability(true),
|
||||||
|
)
|
||||||
code.Register(
|
code.Register(
|
||||||
ErrConversationJsonMarshal,
|
ErrConversationJsonMarshal,
|
||||||
"json marshal failed",
|
"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
|
# Server
|
||||||
export LISTEN_ADDR=":8888"
|
export LISTEN_ADDR=":8888"
|
||||||
export LOG_LEVEL="debug"
|
export LOG_LEVEL="debug"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue