mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-09-28 23:06:14 -04:00
remove errors.Format
This commit is contained in:
parent
6c736b8d57
commit
bc4e2293ef
@ -2,7 +2,6 @@
|
|||||||
package errors
|
package errors
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"v2ray.com/core/common/serial"
|
"v2ray.com/core/common/serial"
|
||||||
@ -28,23 +27,15 @@ type hasSeverity interface {
|
|||||||
|
|
||||||
// Error is an error object with underlying error.
|
// Error is an error object with underlying error.
|
||||||
type Error struct {
|
type Error struct {
|
||||||
format string
|
|
||||||
message []interface{}
|
message []interface{}
|
||||||
inner error
|
inner error
|
||||||
severity Severity
|
severity Severity
|
||||||
path []string
|
path []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Error) formMessage() string {
|
|
||||||
if len(v.format) == 0 {
|
|
||||||
return serial.Concat(v.message...)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(v.format, v.message...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error implements error.Error().
|
// Error implements error.Error().
|
||||||
func (v *Error) Error() string {
|
func (v *Error) Error() string {
|
||||||
msg := v.formMessage()
|
msg := serial.Concat(v.message...)
|
||||||
if v.inner != nil {
|
if v.inner != nil {
|
||||||
msg += " > " + v.inner.Error()
|
msg += " > " + v.inner.Error()
|
||||||
}
|
}
|
||||||
@ -116,14 +107,6 @@ func New(msg ...interface{}) *Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Format(format string, values ...interface{}) *Error {
|
|
||||||
return &Error{
|
|
||||||
format: format,
|
|
||||||
message: values,
|
|
||||||
severity: SeverityInfo,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cause returns the root cause of this error.
|
// Cause returns the root cause of this error.
|
||||||
func Cause(err error) error {
|
func Cause(err error) error {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -191,7 +191,7 @@ func (v *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.Respon
|
|||||||
}
|
}
|
||||||
|
|
||||||
if buffer[0] != v.responseHeader {
|
if buffer[0] != v.responseHeader {
|
||||||
return nil, errors.Format("unexpected response header. Expecting %d but actually %d", v.responseHeader, buffer[0]).Path("Proxy", "VMess", "Encoding", "ClientSession")
|
return nil, errors.New("unexpected response header. Expecting ", int(v.responseHeader), " but actually ", int(buffer[0])).Path("Proxy", "VMess", "Encoding", "ClientSession")
|
||||||
}
|
}
|
||||||
|
|
||||||
header := &protocol.ResponseHeader{
|
header := &protocol.ResponseHeader{
|
||||||
|
@ -45,14 +45,14 @@ func (v *KCPConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
if v.Mtu != nil {
|
if v.Mtu != nil {
|
||||||
mtu := *v.Mtu
|
mtu := *v.Mtu
|
||||||
if mtu < 576 || mtu > 1460 {
|
if mtu < 576 || mtu > 1460 {
|
||||||
return nil, errors.Format("Config: Invalid mKCP MTU size: %d", mtu)
|
return nil, errors.New("Config: Invalid mKCP MTU size: ", mtu)
|
||||||
}
|
}
|
||||||
config.Mtu = &kcp.MTU{Value: mtu}
|
config.Mtu = &kcp.MTU{Value: mtu}
|
||||||
}
|
}
|
||||||
if v.Tti != nil {
|
if v.Tti != nil {
|
||||||
tti := *v.Tti
|
tti := *v.Tti
|
||||||
if tti < 10 || tti > 100 {
|
if tti < 10 || tti > 100 {
|
||||||
return nil, errors.Format("Config: Invalid mKCP TTI: %d", tti)
|
return nil, errors.New("Config: Invalid mKCP TTI: ", tti)
|
||||||
}
|
}
|
||||||
config.Tti = &kcp.TTI{Value: tti}
|
config.Tti = &kcp.TTI{Value: tti}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
panic(errors.Format("Unexpected status %d", resp.StatusCode))
|
panic(errors.New("unexpected status ", resp.StatusCode))
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
scanner := bufio.NewScanner(resp.Body)
|
scanner := bufio.NewScanner(resp.Body)
|
||||||
|
Loading…
Reference in New Issue
Block a user