gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/errors/http-response-error.go (about)

     1  package errors
     2  
     3  import "fmt"
     4  
     5  type HttpResponseError struct {
     6  	Code int
     7  	Msg  string
     8  }
     9  
    10  func (e *HttpResponseError) Error() string {
    11  	if e == nil {
    12  		return "<nil>"
    13  	}
    14  	if e.Msg != "" {
    15  		return fmt.Sprintf("请求返回错误代码(%d), 错误原因: %s", e.Code, e.Msg)
    16  	} else {
    17  		return fmt.Sprintf("请求返回错误代码(%d)", e.Code)
    18  	}
    19  }