Files
v2ray_simple/utils/error.go
hahahrfool 146f7cf926 修复大量与websocket和回落相关的bug;
修复 websocket时无回落的问题
修复 websocket不匹配时直接返回内部错误字符串导致 可探测 的超级bug
修复回落不匹配问题
修复websocket时readv闪退问题

修复 命令行 loglevel参数被配置文件覆盖问题
修复获取tls 的 alpn和 sni时遇到空指针闪退问题

将默认fallback地址的赋值放到通用代码中;
移除 ErrSingleFallback, 改用utils.ErrFirstBuffer
使ws的server可以返回 预设的path
2022-03-24 13:42:34 +08:00

71 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package utils
import (
"bytes"
"fmt"
)
type ErrFirstBuffer struct {
Err error
First *bytes.Buffer
}
func (ef *ErrFirstBuffer) Error() string {
return ef.Err.Error()
}
func NewErr(desc string, e error) *ErrInErr {
return &ErrInErr{
ErrDesc: desc,
ErrDetail: e,
}
}
func NewDataErr(desc string, e error, data interface{}) *ErrInErr {
return &ErrInErr{
ErrDesc: desc,
ErrDetail: e,
Data: data,
}
}
// ErrInErr 很适合一个err包含另一个err并且提供附带数据的情况
type ErrInErr struct {
ErrDesc string
ErrDetail error
Data interface{}
cachedStr string
}
func (e *ErrInErr) Error() string {
return e.String()
}
func (e *ErrInErr) String() string {
if e.cachedStr == "" {
e.cachedStr = e.string()
}
return e.cachedStr
}
func (e *ErrInErr) string() string {
if e.Data != nil {
if e.ErrDetail != nil {
return fmt.Sprintf("%s : %s, Data: %v", e.ErrDesc, e.ErrDetail.Error(), e.Data)
}
return fmt.Sprintf("%s , Data: %v", e.ErrDesc, e.Data)
}
if e.ErrDetail != nil {
return fmt.Sprintf("%s : %s", e.ErrDesc, e.ErrDetail.Error())
}
return e.ErrDesc
}