package qiyuesuosdk import ( "errors" "strings" ) var ( // ErrCompanyNotRegistered 契约锁返回 code=2002002,表示 openCompanyId 尚未注册。 ErrCompanyNotRegistered = errors.New("qiyuesuo: company not registered") // ErrInvalidParams 必填参数缺失。 ErrInvalidParams = errors.New("qiyuesuo: invalid params") // ErrSealCreatePageUnavailable 制章页面链接未返回(可能未开通接口制章)。 ErrSealCreatePageUnavailable = errors.New("qiyuesuo: seal create page unavailable") // ErrSealImageUnavailable 未获取到印章图片。 ErrSealImageUnavailable = errors.New("qiyuesuo: seal image unavailable") // ErrSealNotFound 法人单位下未找到可用电子公章。 ErrSealNotFound = errors.New("qiyuesuo: seal not found") ) type apiResponse struct { Code int `json:"code"` Message string `json:"message"` } func (r apiResponse) err() error { if r.Message == "SUCCESS" || r.Message == "" { return nil } if r.Code == 2002002 { return ErrCompanyNotRegistered } return errors.New("qiyuesuo: " + r.Message) } // IsPersonalSignAuthRecordNotFound 个人静默签授权查询无记录(契约锁业务码,非系统故障)。 func IsPersonalSignAuthRecordNotFound(err error) bool { if err == nil { return false } return strings.Contains(err.Error(), "未查询到静默签授权记录") }