From d55fbd7f8da44a5fa83a9f2cdff7f0dec1617401 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sun, 30 Sep 2018 18:39:53 +0200 Subject: [PATCH] simplify error creation --- app/commander/errors.generated.go | 4 +- app/dispatcher/errors.generated.go | 4 +- app/dns/errors.generated.go | 6 ++- app/log/command/errors.generated.go | 4 +- app/log/errors.generated.go | 6 ++- app/policy/errors.generated.go | 6 ++- app/proxyman/command/errors.generated.go | 4 +- app/proxyman/inbound/errors.generated.go | 4 +- app/proxyman/mux/errors.generated.go | 4 +- app/proxyman/outbound/errors.generated.go | 4 +- app/router/errors.generated.go | 6 ++- app/stats/command/errors.generated.go | 4 +- app/stats/errors.generated.go | 6 ++- common/buf/errors.generated.go | 6 ++- common/crypto/errors.generated.go | 6 ++- common/errors.generated.go | 6 ++- common/errors/errorgen/main.go | 48 ++++++++----------- common/errors/errors.go | 27 +++++++---- common/errors/errors_test.go | 10 ++-- common/net/errors.generated.go | 6 ++- common/platform/ctlcmd/errors.generated.go | 4 +- common/protocol/errors.generated.go | 6 ++- common/protocol/tls/cert/errors.generated.go | 4 +- common/retry/errors.generated.go | 6 ++- errors.generated.go | 6 ++- main/confloader/external/errors.generated.go | 4 +- main/errors.generated.go | 6 ++- main/json/errors.generated.go | 6 ++- proxy/blackhole/errors.generated.go | 4 +- proxy/dokodemo/errors.generated.go | 4 +- proxy/freedom/errors.generated.go | 4 +- proxy/http/errors.generated.go | 6 ++- proxy/mtproto/errors.generated.go | 4 +- proxy/shadowsocks/errors.generated.go | 4 +- proxy/socks/errors.generated.go | 4 +- proxy/vmess/encoding/errors.generated.go | 4 +- proxy/vmess/errors.generated.go | 4 +- proxy/vmess/inbound/errors.generated.go | 4 +- proxy/vmess/outbound/errors.generated.go | 4 +- .../internet/domainsocket/errors.generated.go | 4 +- transport/internet/errors.generated.go | 4 +- .../internet/headers/http/errors.generated.go | 4 +- transport/internet/http/errors.generated.go | 4 +- transport/internet/kcp/errors.generated.go | 4 +- transport/internet/tcp/errors.generated.go | 4 +- transport/internet/tls/errors.generated.go | 4 +- transport/internet/udp/errors.generated.go | 4 +- .../internet/websocket/errors.generated.go | 4 +- 48 files changed, 208 insertions(+), 87 deletions(-) diff --git a/app/commander/errors.generated.go b/app/commander/errors.generated.go index 70edc708..406ec0ca 100644 --- a/app/commander/errors.generated.go +++ b/app/commander/errors.generated.go @@ -2,6 +2,8 @@ package commander import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("App", "Commander") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/app/dispatcher/errors.generated.go b/app/dispatcher/errors.generated.go index 424bd981..e1161609 100644 --- a/app/dispatcher/errors.generated.go +++ b/app/dispatcher/errors.generated.go @@ -2,6 +2,8 @@ package dispatcher import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("App", "Dispatcher") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/app/dns/errors.generated.go b/app/dns/errors.generated.go index 19e34380..ba70372f 100644 --- a/app/dns/errors.generated.go +++ b/app/dns/errors.generated.go @@ -2,4 +2,8 @@ package dns import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("App", "DNS") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/log/command/errors.generated.go b/app/log/command/errors.generated.go index ac6c3bb2..66f78051 100644 --- a/app/log/command/errors.generated.go +++ b/app/log/command/errors.generated.go @@ -2,6 +2,8 @@ package command import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("App", "Log", "Command") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/app/log/errors.generated.go b/app/log/errors.generated.go index 6183c125..3088c811 100644 --- a/app/log/errors.generated.go +++ b/app/log/errors.generated.go @@ -2,4 +2,8 @@ package log import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("App", "Log") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/policy/errors.generated.go b/app/policy/errors.generated.go index 3798ce91..123e8499 100644 --- a/app/policy/errors.generated.go +++ b/app/policy/errors.generated.go @@ -2,4 +2,8 @@ package policy import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("App", "Policy") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/proxyman/command/errors.generated.go b/app/proxyman/command/errors.generated.go index 7c196cf5..66f78051 100644 --- a/app/proxyman/command/errors.generated.go +++ b/app/proxyman/command/errors.generated.go @@ -2,6 +2,8 @@ package command import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("App", "Proxyman", "Command") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/app/proxyman/inbound/errors.generated.go b/app/proxyman/inbound/errors.generated.go index fa3906ff..90d805b1 100644 --- a/app/proxyman/inbound/errors.generated.go +++ b/app/proxyman/inbound/errors.generated.go @@ -2,6 +2,8 @@ package inbound import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("App", "Proxyman", "Inbound") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/app/proxyman/mux/errors.generated.go b/app/proxyman/mux/errors.generated.go index 6cbf45f6..522a6e33 100644 --- a/app/proxyman/mux/errors.generated.go +++ b/app/proxyman/mux/errors.generated.go @@ -2,6 +2,8 @@ package mux import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("App", "Proxyman", "Mux") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/app/proxyman/outbound/errors.generated.go b/app/proxyman/outbound/errors.generated.go index 8302131b..37e984d8 100644 --- a/app/proxyman/outbound/errors.generated.go +++ b/app/proxyman/outbound/errors.generated.go @@ -2,6 +2,8 @@ package outbound import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("App", "Proxyman", "Outbound") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/app/router/errors.generated.go b/app/router/errors.generated.go index 37d2f567..0bd943f5 100644 --- a/app/router/errors.generated.go +++ b/app/router/errors.generated.go @@ -2,4 +2,8 @@ package router import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("App", "Router") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/stats/command/errors.generated.go b/app/stats/command/errors.generated.go index a5030ca0..66f78051 100644 --- a/app/stats/command/errors.generated.go +++ b/app/stats/command/errors.generated.go @@ -2,6 +2,8 @@ package command import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("App", "Stats", "Command") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/app/stats/errors.generated.go b/app/stats/errors.generated.go index 1bfbe328..c2489bea 100644 --- a/app/stats/errors.generated.go +++ b/app/stats/errors.generated.go @@ -2,4 +2,8 @@ package stats import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("App", "Stats") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/common/buf/errors.generated.go b/common/buf/errors.generated.go index c68565bb..5853cd0c 100644 --- a/common/buf/errors.generated.go +++ b/common/buf/errors.generated.go @@ -2,4 +2,8 @@ package buf import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Buf") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/common/crypto/errors.generated.go b/common/crypto/errors.generated.go index cdc756a5..88a2f2ad 100644 --- a/common/crypto/errors.generated.go +++ b/common/crypto/errors.generated.go @@ -2,4 +2,8 @@ package crypto import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Crypto") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/common/errors.generated.go b/common/errors.generated.go index fed38e0e..0c5d71fd 100644 --- a/common/errors.generated.go +++ b/common/errors.generated.go @@ -2,4 +2,8 @@ package common import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Common") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/common/errors/errorgen/main.go b/common/errors/errorgen/main.go index d673d12d..de4cc62d 100644 --- a/common/errors/errorgen/main.go +++ b/common/errors/errorgen/main.go @@ -3,47 +3,39 @@ package main import ( - "flag" "fmt" "log" "os" - "strings" - - "v2ray.com/core/common" -) - -var ( - pkg = flag.String("pkg", "", "Target package") - path = flag.String("path", "", "Path") + "path/filepath" ) -func main() { - flag.Parse() - - if len(*pkg) == 0 { - panic("Package is not specified.") - } - - if len(*path) == 0 { - panic("Path is not specified.") +func getCurrentPkg() (string, error) { + path, err := os.Getwd() + if err != nil { + return "", err } + return filepath.Base(path), nil +} - paths := strings.Split(*path, ",") - for i := range paths { - paths[i] = "\"" + paths[i] + "\"" +func main() { + pkg, err := getCurrentPkg() + if err != nil { + log.Fatal("Failed to get current package: ", err.Error()) + return } - pathStr := strings.Join(paths, ", ") file, err := os.OpenFile("errors.generated.go", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) if err != nil { log.Fatalf("Failed to generate errors.generated.go: %v", err) + return } - common.Must2(fmt.Fprintln(file, "package", *pkg)) - common.Must2(fmt.Fprintln(file, "")) - common.Must2(fmt.Fprintln(file, "import \"v2ray.com/core/common/errors\"")) - common.Must2(fmt.Fprintln(file, "")) - common.Must2(fmt.Fprintln(file, "func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("+pathStr+") }")) + fmt.Fprintln(file, "package", pkg) + fmt.Fprintln(file, "") + fmt.Fprintln(file, "import \"v2ray.com/core/common/errors\"") + fmt.Fprintln(file, "") + fmt.Fprintln(file, "type errPathObjHolder struct {}") + fmt.Fprintln(file, "func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) }") - common.Must(file.Close()) + file.Close() } diff --git a/common/errors/errors.go b/common/errors/errors.go index 8a487c28..265ea813 100644 --- a/common/errors/errors.go +++ b/common/errors/errors.go @@ -3,7 +3,7 @@ package errors // import "v2ray.com/core/common/errors" import ( "os" - "strings" + "reflect" "v2ray.com/core/common/log" "v2ray.com/core/common/serial" @@ -20,21 +20,34 @@ type hasSeverity interface { // Error is an error object with underlying error. type Error struct { + pathObj interface{} prefix []interface{} - path []string message []interface{} inner error severity log.Severity } +func (err *Error) WithPathObj(obj interface{}) *Error { + err.pathObj = obj + return err +} + +func (err *Error) pkgPath() string { + if err.pathObj == nil { + return "" + } + return reflect.TypeOf(err.pathObj).PkgPath() +} + // Error implements error.Error(). func (v *Error) Error() string { msg := serial.Concat(v.message...) if v.inner != nil { msg += " > " + v.inner.Error() } - if len(v.path) > 0 { - msg = strings.Join(v.path, "|") + ": " + msg + path := v.pkgPath() + if len(path) > 0 { + msg = path + ": " + msg } var prefix string @@ -98,12 +111,6 @@ func (v *Error) AtError() *Error { return v.atSeverity(log.Severity_Error) } -// Path sets the path to the location where this error happens. -func (v *Error) Path(path ...string) *Error { - v.path = path - return v -} - // String returns the string representation of this error. func (v *Error) String() string { return v.Error() diff --git a/common/errors/errors_test.go b/common/errors/errors_test.go index 480f325e..bda3ded3 100644 --- a/common/errors/errors_test.go +++ b/common/errors/errors_test.go @@ -28,18 +28,20 @@ func TestError(t *testing.T) { assert(err.Error(), HasSubstring, "EOF") } +type e struct{} + func TestErrorMessage(t *testing.T) { data := []struct { err error msg string }{ { - err: New("a").Base(New("b")).Path("c", "d", "e"), - msg: "c|d|e: a > b", + err: New("a").Base(New("b")).WithPathObj(e{}), + msg: "v2ray.com/core/common/errors_test: a > b", }, { - err: New("a").Base(New("b").Path("c")).Path("d", "e"), - msg: "d|e: a > c: b", + err: New("a").Base(New("b").WithPathObj(e{})), + msg: "a > v2ray.com/core/common/errors_test: b", }, } diff --git a/common/net/errors.generated.go b/common/net/errors.generated.go index b5acb2d0..e3cf99fb 100644 --- a/common/net/errors.generated.go +++ b/common/net/errors.generated.go @@ -2,4 +2,8 @@ package net import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Net") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/common/platform/ctlcmd/errors.generated.go b/common/platform/ctlcmd/errors.generated.go index fb4a0f1d..91233667 100644 --- a/common/platform/ctlcmd/errors.generated.go +++ b/common/platform/ctlcmd/errors.generated.go @@ -2,6 +2,8 @@ package ctlcmd import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Command", "Platform", "CtlCmd") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/common/protocol/errors.generated.go b/common/protocol/errors.generated.go index 74feea6f..2b52880a 100644 --- a/common/protocol/errors.generated.go +++ b/common/protocol/errors.generated.go @@ -2,4 +2,8 @@ package protocol import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Protocol") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/common/protocol/tls/cert/errors.generated.go b/common/protocol/tls/cert/errors.generated.go index aba7187e..9695be34 100644 --- a/common/protocol/tls/cert/errors.generated.go +++ b/common/protocol/tls/cert/errors.generated.go @@ -2,6 +2,8 @@ package cert import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Protocol", "TLS", "Cert") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/common/retry/errors.generated.go b/common/retry/errors.generated.go index 54a75ea5..db19a63d 100644 --- a/common/retry/errors.generated.go +++ b/common/retry/errors.generated.go @@ -2,4 +2,8 @@ package retry import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Retry") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/errors.generated.go b/errors.generated.go index 74b226f5..2f4c8644 100644 --- a/errors.generated.go +++ b/errors.generated.go @@ -2,4 +2,8 @@ package core import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Core") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/main/confloader/external/errors.generated.go b/main/confloader/external/errors.generated.go index 891daaaf..919f10d0 100644 --- a/main/confloader/external/errors.generated.go +++ b/main/confloader/external/errors.generated.go @@ -2,6 +2,8 @@ package external import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Main", "ConfLoader", "External") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/main/errors.generated.go b/main/errors.generated.go index 4ef31b1f..ed27b93a 100644 --- a/main/errors.generated.go +++ b/main/errors.generated.go @@ -2,4 +2,8 @@ package main import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Main") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/main/json/errors.generated.go b/main/json/errors.generated.go index faf694b9..654bc88e 100644 --- a/main/json/errors.generated.go +++ b/main/json/errors.generated.go @@ -2,4 +2,8 @@ package json import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Main", "Json") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/proxy/blackhole/errors.generated.go b/proxy/blackhole/errors.generated.go index 5c2e2d8a..e985de40 100644 --- a/proxy/blackhole/errors.generated.go +++ b/proxy/blackhole/errors.generated.go @@ -2,6 +2,8 @@ package blackhole import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "Blackhole") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/proxy/dokodemo/errors.generated.go b/proxy/dokodemo/errors.generated.go index 9b8537cd..23562ab4 100644 --- a/proxy/dokodemo/errors.generated.go +++ b/proxy/dokodemo/errors.generated.go @@ -2,6 +2,8 @@ package dokodemo import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "Dokodemo") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/proxy/freedom/errors.generated.go b/proxy/freedom/errors.generated.go index 16193718..b4ca934c 100644 --- a/proxy/freedom/errors.generated.go +++ b/proxy/freedom/errors.generated.go @@ -2,6 +2,8 @@ package freedom import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "Freedom") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/proxy/http/errors.generated.go b/proxy/http/errors.generated.go index 8a4fa769..9c6e8e4c 100644 --- a/proxy/http/errors.generated.go +++ b/proxy/http/errors.generated.go @@ -2,4 +2,8 @@ package http import "v2ray.com/core/common/errors" -func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("Proxy", "HTTP") } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/proxy/mtproto/errors.generated.go b/proxy/mtproto/errors.generated.go index 9102db09..52352d70 100644 --- a/proxy/mtproto/errors.generated.go +++ b/proxy/mtproto/errors.generated.go @@ -2,6 +2,8 @@ package mtproto import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "MTProto") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/proxy/shadowsocks/errors.generated.go b/proxy/shadowsocks/errors.generated.go index c6111ce6..42d6d3fe 100644 --- a/proxy/shadowsocks/errors.generated.go +++ b/proxy/shadowsocks/errors.generated.go @@ -2,6 +2,8 @@ package shadowsocks import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "Shadowsocks") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/proxy/socks/errors.generated.go b/proxy/socks/errors.generated.go index 03b2a2f3..a4886798 100644 --- a/proxy/socks/errors.generated.go +++ b/proxy/socks/errors.generated.go @@ -2,6 +2,8 @@ package socks import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "Socks") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/proxy/vmess/encoding/errors.generated.go b/proxy/vmess/encoding/errors.generated.go index 99b3a4f6..6fb68210 100644 --- a/proxy/vmess/encoding/errors.generated.go +++ b/proxy/vmess/encoding/errors.generated.go @@ -2,6 +2,8 @@ package encoding import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "VMess", "Encoding") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/proxy/vmess/errors.generated.go b/proxy/vmess/errors.generated.go index 5a78d604..cc044be3 100644 --- a/proxy/vmess/errors.generated.go +++ b/proxy/vmess/errors.generated.go @@ -2,6 +2,8 @@ package vmess import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "VMess") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/proxy/vmess/inbound/errors.generated.go b/proxy/vmess/inbound/errors.generated.go index 620fd842..90d805b1 100644 --- a/proxy/vmess/inbound/errors.generated.go +++ b/proxy/vmess/inbound/errors.generated.go @@ -2,6 +2,8 @@ package inbound import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "VMess", "Inbound") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/proxy/vmess/outbound/errors.generated.go b/proxy/vmess/outbound/errors.generated.go index db918b89..37e984d8 100644 --- a/proxy/vmess/outbound/errors.generated.go +++ b/proxy/vmess/outbound/errors.generated.go @@ -2,6 +2,8 @@ package outbound import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Proxy", "VMess", "Outbound") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/transport/internet/domainsocket/errors.generated.go b/transport/internet/domainsocket/errors.generated.go index 4c7d440e..645ddaa7 100644 --- a/transport/internet/domainsocket/errors.generated.go +++ b/transport/internet/domainsocket/errors.generated.go @@ -2,6 +2,8 @@ package domainsocket import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Transport", "Internet", "DomainSocket") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/transport/internet/errors.generated.go b/transport/internet/errors.generated.go index b174468e..b1c035dd 100644 --- a/transport/internet/errors.generated.go +++ b/transport/internet/errors.generated.go @@ -2,6 +2,8 @@ package internet import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Transport", "Internet") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/transport/internet/headers/http/errors.generated.go b/transport/internet/headers/http/errors.generated.go index 1c7b1d29..9c6e8e4c 100644 --- a/transport/internet/headers/http/errors.generated.go +++ b/transport/internet/headers/http/errors.generated.go @@ -2,6 +2,8 @@ package http import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Transport", "Internet", "Headers", "HTTP") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/transport/internet/http/errors.generated.go b/transport/internet/http/errors.generated.go index d89f957d..9c6e8e4c 100644 --- a/transport/internet/http/errors.generated.go +++ b/transport/internet/http/errors.generated.go @@ -2,6 +2,8 @@ package http import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Transport", "Internet", "HTTP") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/transport/internet/kcp/errors.generated.go b/transport/internet/kcp/errors.generated.go index ebae01c1..1f342be9 100644 --- a/transport/internet/kcp/errors.generated.go +++ b/transport/internet/kcp/errors.generated.go @@ -2,6 +2,8 @@ package kcp import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Transport", "Internet", "mKCP") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/transport/internet/tcp/errors.generated.go b/transport/internet/tcp/errors.generated.go index 5dfb2a2b..e1ad6289 100644 --- a/transport/internet/tcp/errors.generated.go +++ b/transport/internet/tcp/errors.generated.go @@ -2,6 +2,8 @@ package tcp import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Transport", "Internet", "TCP") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/transport/internet/tls/errors.generated.go b/transport/internet/tls/errors.generated.go index d48428e9..080eeb74 100644 --- a/transport/internet/tls/errors.generated.go +++ b/transport/internet/tls/errors.generated.go @@ -2,6 +2,8 @@ package tls import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Transport", "Internet", "TLS") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/transport/internet/udp/errors.generated.go b/transport/internet/udp/errors.generated.go index 33667b60..62a87570 100644 --- a/transport/internet/udp/errors.generated.go +++ b/transport/internet/udp/errors.generated.go @@ -2,6 +2,8 @@ package udp import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Transport", "Internet", "UDP") + return errors.New(values...).WithPathObj(errPathObjHolder{}) } diff --git a/transport/internet/websocket/errors.generated.go b/transport/internet/websocket/errors.generated.go index b94bfcdb..1633cdf0 100644 --- a/transport/internet/websocket/errors.generated.go +++ b/transport/internet/websocket/errors.generated.go @@ -2,6 +2,8 @@ package websocket import "v2ray.com/core/common/errors" +type errPathObjHolder struct{} + func newError(values ...interface{}) *errors.Error { - return errors.New(values...).Path("Transport", "Internet", "WebSocket") + return errors.New(values...).WithPathObj(errPathObjHolder{}) }