1 Star 0 Fork 0

tianji-lab/gosip

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
error.go 683 Bytes
一键复制 编辑 原始数据 按行查看 历史
Mark 提交于 2023-07-31 19:46 +08:00 . fork init
package sip
import "fmt"
type RequestError struct {
Request Request
Response Response
Code uint
Reason string
}
func NewRequestError(code uint, reason string, request Request, response Response) *RequestError {
err := &RequestError{
Code: code,
Reason: reason,
}
if request != nil {
err.Request = CopyRequest(request)
}
if response != nil {
err.Response = CopyResponse(response)
}
return err
}
func (err *RequestError) Error() string {
if err == nil {
return "<nil>"
}
reason := err.Reason
if err.Code != 0 {
reason += fmt.Sprintf(" (Code %d)", err.Code)
}
return fmt.Sprintf("sip.RequestError: request failed with reason '%s'", reason)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tinaji-lab/gosip.git
git@gitee.com:tinaji-lab/gosip.git
tinaji-lab
gosip
gosip
v0.0.1

搜索帮助