error.go 638 B

123456789101112131415161718192021222324252627282930
  1. package Core
  2. import "C"
  3. import (
  4. "strconv"
  5. )
  6. // 构造HcnetError
  7. func NewHcnetError(Code int, Msg string, FuncName string) *HcnetError {
  8. return &HcnetError{Code: Code, Msg: Msg, FuncName: FuncName}
  9. }
  10. // 海康网络sdk自定义错误
  11. type HcnetError struct {
  12. Code int `json:"Code"` // 错误码
  13. Msg string `json:"Msg"` // 错误码描述
  14. FuncName string `json:"FuncName"`
  15. }
  16. func (p *HcnetError) Error() string {
  17. return strconv.FormatInt(int64(p.Code), 10) + "," + p.Msg
  18. }
  19. func (p *HcnetError) IsPasswordError() bool {
  20. return p.Code == 1
  21. }
  22. func (p *HcnetError) IsDeviceOfflineError() bool {
  23. return p.Code == 7
  24. }