浏览代码

fix error usage

Darien Raymond 7 年之前
父节点
当前提交
14176a340d
共有 2 个文件被更改,包括 3 次插入4 次删除
  1. 1 2
      proxy/vmess/account.go
  2. 2 2
      proxy/vmess/inbound/inbound.go

+ 1 - 2
proxy/vmess/account.go

@@ -31,8 +31,7 @@ func (a *InternalAccount) Equals(account protocol.Account) bool {
 func (a *Account) AsAccount() (protocol.Account, error) {
 	id, err := uuid.ParseString(a.Id)
 	if err != nil {
-		newError("failed to parse ID").Base(err).AtError().WriteToLog()
-		return nil, err
+		return nil, newError("failed to parse ID").Base(err).AtError()
 	}
 	protoID := protocol.NewID(id)
 	return &InternalAccount{

+ 2 - 2
proxy/vmess/inbound/inbound.go

@@ -185,7 +185,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
 				Status: log.AccessRejected,
 				Reason: err,
 			})
-			newError("invalid request from ", connection.RemoteAddr(), ": ", err).AtInfo().WriteToLog()
+			err = newError("invalid request from ", connection.RemoteAddr()).Base(err).AtInfo()
 		}
 		return err
 	}
@@ -252,7 +252,7 @@ func (h *Handler) generateCommand(ctx context.Context, request *protocol.Request
 		if h.inboundHandlerManager != nil {
 			handler, err := h.inboundHandlerManager.GetHandler(ctx, tag)
 			if err != nil {
-				newError("failed to get detour handler: ", tag, err).AtWarning().WriteToLog()
+				newError("failed to get detour handler: ", tag).Base(err).AtWarning().WriteToLog()
 				return nil
 			}
 			proxyHandler, port, availableMin := handler.GetRandomInboundProxy()