代码拉取完成,页面将自动刷新
package direwolf
import (
"errors"
"fmt"
"runtime"
"strconv"
"time"
)
var (
ErrRequestBody = errors.New("request body can`t coexists with PostForm")
ErrTimeout = errors.New("reqeust timeout")
)
type RedirectError struct {
RedirectNum int
}
func (e *RedirectError) Error() string {
return "exceeded the maximum number of redirects: " + strconv.Itoa(e.RedirectNum)
}
type Error struct {
// wrapped error
err error
msg string
// file path and name
file string
fileLine int
time string
}
func (e *Error) Error() string {
_, ok := e.err.(interface {
Unwrap() error
})
if ok {
return fmt.Sprintf("%s - %s:%d\n%s\n%s", e.time, e.file, e.fileLine, e.msg, e.err.Error())
}
return fmt.Sprintf("%s - %s:%d\n%s\n\n%s\n", e.time, e.file, e.fileLine, e.msg, e.err.Error())
}
func (e *Error) Unwrap() error {
if e.err != nil {
return e.err
}
return nil
}
// WrapErr will wrap a error with some information: filename, line, time and some message.
func WrapErr(err error, msg string) error {
_, file, line, _ := runtime.Caller(1)
return &Error{
err: err,
msg: msg,
file: file,
fileLine: line,
time: time.Now().Format("2006-01-02 15:04:05"),
}
}
// WrapErr will wrap a error with some information: filename, line, time and some message.
// You can format message of error.
func WrapErrf(err error, format string, args ...interface{}) error {
msg := fmt.Sprintf(format, args...)
_, file, line, _ := runtime.Caller(1)
return &Error{
err: err,
msg: msg,
file: file,
fileLine: line,
time: time.Now().Format("2006-01-02 15:04:05"),
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。