mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-12-24 13:27:56 +08:00
utils.Errs -> utils.ErrList
This commit is contained in:
@@ -66,12 +66,12 @@ func shadowTls1(servername string, clientConn net.Conn) (err error) {
|
||||
<-finish1
|
||||
|
||||
if e1 != nil || e2 != nil {
|
||||
e := utils.Errs{}
|
||||
e := utils.ErrList{}
|
||||
if e1 != nil {
|
||||
e.Add(utils.ErrsItem{Index: 1, E: e1})
|
||||
e.Add(utils.ErrItem{Index: 1, E: e1})
|
||||
}
|
||||
if e2 != nil {
|
||||
e.Add(utils.ErrsItem{Index: 2, E: e2})
|
||||
e.Add(utils.ErrItem{Index: 2, E: e2})
|
||||
}
|
||||
|
||||
return e
|
||||
|
||||
@@ -145,22 +145,22 @@ func (e ErrInErr) String() string {
|
||||
|
||||
}
|
||||
|
||||
type Errs struct {
|
||||
List []ErrsItem
|
||||
type ErrList struct {
|
||||
List []ErrItem
|
||||
}
|
||||
|
||||
type ErrsItem struct {
|
||||
type ErrItem struct {
|
||||
Index int
|
||||
E error
|
||||
}
|
||||
|
||||
func (ee *Errs) Add(e ErrsItem) {
|
||||
func (ee *ErrList) Add(e ErrItem) {
|
||||
ee.List = append(ee.List, e)
|
||||
}
|
||||
func (e Errs) OK() bool {
|
||||
func (e ErrList) OK() bool {
|
||||
return len(e.List) == 0
|
||||
}
|
||||
func (e Errs) String() string {
|
||||
func (e ErrList) String() string {
|
||||
var sb strings.Builder
|
||||
for _, err := range e.List {
|
||||
sb.WriteString(strconv.Itoa(err.Index))
|
||||
@@ -174,6 +174,6 @@ func (e Errs) String() string {
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func (e Errs) Error() string {
|
||||
func (e ErrList) Error() string {
|
||||
return e.String()
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func ClassicCopy_detailErr(w io.Writer, r io.Reader) (written int64, err error)
|
||||
}
|
||||
written += int64(nw)
|
||||
if ew != nil {
|
||||
err = ErrInErr{ErrDetail: Errs{[]ErrsItem{{Index: 1, E: ErrInErr{ErrDetail: ew, Data: []int{nr, nw}}}, {Index: 2, E: er}}}, ErrDesc: "ew"}
|
||||
err = ErrInErr{ErrDetail: ErrList{[]ErrItem{{Index: 1, E: ErrInErr{ErrDetail: ew}}, {Index: 2, E: er}}}, ErrDesc: "ew", Data: []int{nr, nw}}
|
||||
break
|
||||
}
|
||||
if nr != nw {
|
||||
@@ -286,11 +286,11 @@ type MultiCloser struct {
|
||||
|
||||
func (cc *MultiCloser) Close() (result error) {
|
||||
cc.Once.Do(func() {
|
||||
var es Errs
|
||||
var es ErrList
|
||||
for i, c := range cc.Closers {
|
||||
e := c.Close()
|
||||
if e != nil {
|
||||
es.Add(ErrsItem{Index: i, E: e})
|
||||
es.Add(ErrItem{Index: i, E: e})
|
||||
}
|
||||
}
|
||||
if !es.OK() {
|
||||
|
||||
Reference in New Issue
Block a user