當前位置: 首頁>>代碼示例>>Golang>>正文


Golang utils.Error函數代碼示例

本文整理匯總了Golang中cn/agree/utils.Error函數的典型用法代碼示例。如果您正苦於以下問題:Golang Error函數的具體用法?Golang Error怎麽用?Golang Error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Error函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ReadData

func (p *IdcProtocol) ReadData(r *http.Request, arg *JsonGeneralInputAgr, res *JsonResponse) error {
	utils.Debug("received Idccard ReadData request,arg is : %+v", *arg)

	f, a, err := getIDCImpl()
	if err != nil {
		utils.Error("get Idc impl error: %s", err.Error())
		res.Code = driverlayer.DEVICE_IN_USE
		res.ErrMsg = err.Error()
		utils.Debug("end Idc ReadData request")
		return nil
	}

	defer MarkDeviceIDLE(IDR)
	s, err := f.ReadData(a, arg.Timeout)
	if err != nil {
		utils.Error("invoke Idccard read error:%s", err.Error())
		res.Code = driverlayer.DEVICE_OPER_ERROR
		res.ErrMsg = ""
		res.ResMsg = string(s)
	} else {
		res.Code = driverlayer.DEVICE_OPER_SUCCESS
		res.ErrMsg = ""
		res.ResMsg = string(s)
		utils.Debug("IdcProtocol ReadData success")
	}
	utils.Debug("end Idccard ReadData request")

	return nil
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:29,代碼來源:idcprotocol.go

示例2: GenARQC

//從ic卡獲取arqc
func (p *IcProtocol) GenARQC(r *http.Request, arg *JsonICInputAgr, res *JsonResponse) error {
	utils.Debug("received iccard GenARQC request,arg is :%+v", *arg)
	var out []byte
	f, a, err := getICImpl()

	if err != nil {
		utils.Error("get ic impl error: %s", err.Error())
		res.Code = driverlayer.DEVICE_IN_USE
		res.ErrMsg = err.Error()
		utils.Debug("end ic GenARQC request")
		return nil
	}

	defer MarkDeviceIDLE(IC)
	out, err = f.GenARQC(a, arg.Timeout, []byte(arg.TagList), []byte(arg.LpicAppData))
	if err != nil {
		utils.Error("invoke iccard GenARQC error:%s", err.Error())
		res.Code = driverlayer.DEVICE_OPER_ERROR
		res.ErrMsg = string(err.Error())
	} else {
		res.Code = driverlayer.DEVICE_OPER_SUCCESS
		res.ResMsg = string(out)
		utils.Debug("received GenARQC read")
	}
	utils.Debug("end iccard GenARQC request")

	return nil
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:29,代碼來源:icprotocol.go

示例3: GetValidateFg

func (p *FinProtocol) GetValidateFg(r *http.Request, arg *JsonGeneralInputAgr, res *JsonResponse) error {
	utils.Debug("received FinProtocol GetValidateFg request,arg is : %+v", *arg)

	f, a, err := getFingerImpl()
	if err != nil {
		utils.Error("get fin impl error: %s", err.Error())
		res.Code = driverlayer.DEVICE_IN_USE
		res.ErrMsg = err.Error()
		utils.Debug("end fin GetValidateFg request")
		return nil
	}

	defer MarkDeviceIDLE(FP)
	s, err := f.GetValidateFg(a, arg.Timeout)
	if err != nil {
		utils.Error("invoke GetValidateFg read error: %s", err.Error())
		res.Code = driverlayer.DEVICE_OPER_ERROR
		res.ErrMsg = err.Error()
	} else {
		res.Code = driverlayer.DEVICE_OPER_SUCCESS
		res.ResMsg = string(s)
		utils.Debug("fin GetValidateFg request success,reteive data %s", string(s))

	}
	utils.Debug("end FinProtocol GetValidateFg request")
	return nil
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:27,代碼來源:finprotocol.go

示例4: Read

func (p *MsfProtocol) Read(r *http.Request, arg *JsonGeneralReadInputAgr, res *JsonResponse) error {
	utils.Debug("received MsfProtocol read request,arg is : %+v", *arg)
	f, a, err := getMSFImpl()
	if err != nil {
		utils.Error("get msf impl error: %s", err.Error())
		res.Code = driverlayer.DEVICE_IN_USE
		res.ErrMsg = err.Error()
		utils.Debug("end MsfProtocol Read request")

		return nil
	}
	defer MarkDeviceIDLE(MSF)
	s, err := f.Read(a, arg.Readtype, arg.Timeout)
	if err != nil {
		utils.Error("invoke msf read error:%s", err.Error())
		res.Code = driverlayer.DEVICE_OPER_ERROR
		res.ResMsg = string(s)
	} else {
		res.Code = driverlayer.DEVICE_OPER_SUCCESS
		res.ResMsg = string(s)
		utils.Debug("MsfProtocol read success %s", string(s))
	}
	utils.Debug("end MsfProtocol read request")
	return nil
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:25,代碼來源:msfprotocol.go

示例5: StartEstimate

func (p *PingjiaProtocol) StartEstimate(r *http.Request, arg *JsonGeneralInputAgr, res *JsonResponse) error {
	utils.Debug("received PingjiaProtocol StartEstimate request,arg is : %+v", *arg)

	f, a, err := getPingjiaImpl()
	if err != nil {
		utils.Error("get Pingjia impl error: %s", err.Error())
		res.Code = driverlayer.DEVICE_IN_USE
		res.ErrMsg = err.Error()
		utils.Debug("end fin StartEstimate request")
		return nil
	}

	defer MarkDeviceIDLE(PINGJIA)
	s, err := f.StartEsitimate(a, arg.Timeout)
	if err != nil {
		utils.Error("invoke StartEstimate read error: %s", err.Error())
		res.Code = driverlayer.DEVICE_OPER_ERROR
		res.ErrMsg = err.Error()
	} else {
		res.Code = driverlayer.DEVICE_OPER_SUCCESS
		res.ResMsg = string(s)
		utils.Debug("Pingjia StartEstimate request success,reteive data %s", string(s))

	}
	utils.Debug("end PingjiaProtocol StartEstimate request")
	return nil
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:27,代碼來源:pingjiaprotocol.go

示例6: parsePosCommonAttribute

//解析通用的屬性
func parsePosCommonAttribute(cur dom.Element, ps PrintPosInterface) {
	var tmp string
	var fval float64
	var err error
	tmp, err = getAttr(cur.Attr(), "Width")
	if err == nil {
		fval, err = strconv.ParseFloat(tmp, 32)
		if err != nil {
			utils.Error("can't format Height attribute %s,expected int value", tmp)
		}
		ps.SetWidth(float32(fval))
	}

	tmp, err = getAttr(cur.Attr(), "Height")
	if err == nil {
		fval, err = strconv.ParseFloat(tmp, 32)
		if err != nil {
			utils.Error("can't format Height attribute %s,expected int value", tmp)
		}
		ps.SetHeight(float32(fval))
	}

	tmp, err = getAttr(cur.Attr(), "Pos")
	ps.SetPos(tmp)

	tmp, err = getAttr(cur.Attr(), "Align")
	ps.SetAlign(tmp)

	tmp, err = getAttr(cur.Attr(), "Left")
	ps.SetLeft(tmp)

	tmp, err = getAttr(cur.Attr(), "Top")
	ps.SetTop(tmp)
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:35,代碼來源:printparser.go

示例7: CalcExtentValue

//計算規則:
//表示一個Table中的一行,移動X坐標為起始位置,移動Y坐標為下一行
//Tr的設置:X坐標設為Table的起始坐標
//          Y坐標移動一個間距
//這裏需要注意:很有可能會出現Td一行排列不下,進而往下移的情況。
//長度為最高的Td的長度。如果有需要,調整td的長度
func (j *PrintTr) CalcExtentValue(pc *PrintCurState) {
	//尋找最高高度
	s := findChildMaxValue(j, 2)
	//尋找累計寬度
	t := findChildCalValue(j, 1)

	utils.Trace("find tr max height [%f]", s)

	par := findparentPosNodeWithName(j, "Table")
	if par == nil {
		utils.Error("can't find Tr's parent node,maybe error")
		return
	}

	table, found2 := par.(*PrintTable)
	if !found2 {
		utils.Error("table element can't convert to PrintTable,maybe error")
		return
	}
	pc.CurX = par.GetRealLeft()
	j.SetRealHeight(s)
	j.SetRealWidth(t)

	//加上表格寬度
	pc.CurY += (s + table.LineSeperate)

}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:33,代碼來源:printtr.go

示例8: PowerOff

//下電
func (p *IcProtocol) PowerOff(r *http.Request, arg *JsonGeneralInputAgr, res *JsonResponse) error {
	utils.Debug("received iccard PowerOff request,arg is :%+v", *arg)

	f, a, err := getICImpl()

	if err != nil {
		utils.Error("get ic impl error: %s", err.Error())
		res.Code = driverlayer.DEVICE_IN_USE
		res.ErrMsg = err.Error()
		utils.Debug("end ic PowerOff request")
		return nil
	}

	defer MarkDeviceIDLE(IC)
	err = f.PowerOff(a, arg.Timeout)
	if err != nil {
		utils.Error("invoke iccard PowerOff error:%s", err.Error())
		res.Code = driverlayer.DEVICE_OPER_ERROR
		res.ErrMsg = ""
		res.ResMsg = string(err.Error())
	} else {
		res.Code = driverlayer.DEVICE_OPER_SUCCESS
		res.ErrMsg = ""
		utils.Debug("received PowerOff read")
	}
	utils.Debug("end iccard PowerOff request")

	return nil
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:30,代碼來源:icprotocol.go

示例9: Readonce

func (p *PinProtocol) Readonce(r *http.Request, arg *JsonGeneralInputAgr, res *JsonResponse) error {
	utils.Debug("received pin readonce request,arg is : %+v", *arg)

	f, a, err := getPinImpl()
	if err != nil {
		utils.Error("get pin impl error: %s", err.Error())
		res.Code = driverlayer.DEVICE_IN_USE
		res.ErrMsg = err.Error()
		utils.Debug("end pin readonce request")
		return nil
	}

	defer MarkDeviceIDLE(PIN)
	s, err := f.Readonce(a, arg.Timeout)

	if err != nil {
		utils.Error("invoke pin Readonce error: %s", err.Error())
		res.Code = driverlayer.DEVICE_OPER_ERROR
		res.ErrMsg = err.Error()
	} else {
		res.Code = driverlayer.DEVICE_OPER_SUCCESS
		res.ResMsg = string(s)
		utils.Debug("pin Readonce request success,reteive data %s", string(s))
	}
	utils.Debug("end pin readonce request")

	return nil
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:28,代碼來源:pinprotocol.go

示例10: StartLocalDebugServer

//開啟調試服務
func StartLocalDebugServer() {
	port := "8887"

	tcpAddr, err1 := net.ResolveTCPAddr("tcp4", "0.0.0.0:"+port)
	if err1 != nil {
		utils.Error("start resolving socket error:%s", err1.Error())
		return
	}

	tcpListener, err2 := net.ListenTCP("tcp", tcpAddr) //監聽
	if err2 != nil {
		utils.Error("start listening debug socket error:%s", err2.Error())
		return
	} else {
		utils.Info("debug server start listening ip 0.0.0.0 port %s", port)
	}

	defer tcpListener.Close()
	for {
		tcpConn, err3 := tcpListener.AcceptTCP()
		if err3 != nil {
			utils.Error("establish tcp connection error:%s", err3.Error())
			continue
		}
		go handleLocalConn(tcpConn) //起一個goroutine處理
	}

}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:29,代碼來源:debugserver.go

示例11: SaveAllDevConfig

//保存所有設備配置
func (p *ConfigProtocol) SaveAllDevConfig(r *http.Request, arg *JsonConfigInputAgr, res *JsonResponse) error {
	utils.Debug("received ConfigProtocol SaveAllDevConfig request")
	var (
		n  dom.Node
		t  dom.Element
		dt dom.Attribute
	)
	db := dom.NewDOMBuilder(strings.NewReader(arg.Content), dom.NewDOMStore())
	d, err2 := db.Build()
	if err2 != nil {
		res.Code = 1
		res.ErrMsg = fmt.Sprintf("parse xml file error,category :[%+v] ", err2.Error())
		utils.Error("parse xml file error,category:[%+v]", err2.Error())
		return nil
	}

	f := d.ChildNodes()

	for i := 0; i < len(f); i++ {
		n = f[i]
		switch n.Kind() {
		case dom.ElementKind:
			t = n.(dom.Element)
			switch t.Name() {
			case "Device": // 解析設置
				var v []dom.Attribute
				v = t.Attr()
				for j := 0; j < len(v); j++ {
					dt = v[j]
					if strings.EqualFold(dt.Name(), "Category") {
						err := SaveDrvConfig(dt.Value(), t.String())

						if err != nil {
							res.Code = 1
							res.ErrMsg = fmt.Sprintf("save file error,category :%s  content is : [%s]", dt.Value(), t.String())
							utils.Error("can't save category [%s] ,content is : [%s]", dt.Value(), t.String())
							return nil
						}
					}
				}
				break

			default:
				utils.Error("can't recognize element name: %s", t.Name())
			}
			break
		}
	}

	res.Code = 0

	utils.Debug("end ConfigProtocol SaveAllDevConfig request")
	return nil
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:55,代碼來源:configprotocol.go

示例12: GetValidateFg

//注冊指紋
func (jst *ZZFinger) GetValidateFg(pin *driverlayer.DriverArg, timeout int) ([]byte, error) {
	utils.Debug("receive ZZFinger GetRegisterFg request")

	var term_type int = 0
	var func_id int = 1
	var buf_size int = 1024
	var func_arg int = 1

	t := make([]byte, 1024)
	tty_name := make([]byte, 1)
	tty_name[0] = 0

	var func_arg_pointer []*byte
	func_arg_pointer = make([]*byte, 1)

	_, port, _ := driverlayer.GetPortDescription(pin.Port)

	func_arg_pointer[0] = &([]byte("X"))[0]

	r, _, _ := dllinterop.CallProc(jst.read, uintptr(term_type), uintptr(unsafe.Pointer(&tty_name[0])),
		uintptr(port), uintptr(timeout), uintptr(func_id),
		uintptr(func_arg), uintptr(unsafe.Pointer(&func_arg_pointer[0])), uintptr(unsafe.Pointer(&t[0])), uintptr(buf_size))

	if int(r) == 0 {
		return t, nil
	} else {
		empocc := utils.IndexByteRune(t, 0, 1)
		if empocc != -1 {
			t = t[0:empocc]
		}
		out, _ := utils.TransUTF8FromCode(t, utils.GBK)
		utils.Error("end ZZFinger GetRegisterFg request error %s", string(out))
		return nil, errors.New(string(out))
	}
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:36,代碼來源:zzfinger.go

示例13: populateArg

//組裝arg,如果有不是通用參數的,則放入extractarg中
func populateArg(ps []DevParam) *driverlayer.DriverArg {
	t := driverlayer.DriverArg{}
	t.Baud = 9600
	for _, v := range ps {
		switch v.Name {
		case "Factory":
			t.FactoryName = v.Value
			break

		case "Port":
			t.Port = v.Value
			break

		case "ExtPort":
			t.ExtPort = v.Value
			break

		case "Baud":
			p, err := strconv.Atoi(v.Value)
			if err != nil {
				utils.Error("parse Baud error,set default value 9600 : %+v", v)
				continue
			}
			t.Baud = p
			break

		default:
			ext := driverlayer.DriverExtraParam{Name: v.Name, Value: v.Value}
			t.ExtraParam = append(t.ExtraParam, ext)
		}
	}
	return &t
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:34,代碼來源:driverfacade.go

示例14: Initdriver

func (jst *IDCGeneral) Initdriver(pin *driverlayer.DriverArg) {
	var err error
	jst.termdll, err = syscall.LoadLibrary("third_party/general/sdtapi.dll")
	if err != nil {
		panic("load library error:" + err.Error())
	}

	f := func(n string, res *uintptr) bool {
		*res, err = syscall.GetProcAddress(jst.termdll, n)
		if err != nil {
			syscall.FreeLibrary(jst.termdll)
			panic("load proc " + n + " error:" + err.Error())
		}
		return true
	}

	//獲得dll的各種handle
	if f("SDT_OpenPort", &jst.initcomm) &&
		f("SDT_ClosePort", &jst.closecomm) &&
		f("SDT_StartFindIDCard", &jst.findcard) &&
		f("SDT_SelectIDCard", &jst.selectcard) &&
		f("SDT_ReadBaseMsg", &jst.readbasemsg) {
	} else {
		utils.Error("Init shensi Driver error...%s", err.Error())
	}

}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:27,代碼來源:idcgeneral.go

示例15: RunPr2Engine

func RunPr2Engine(s string, pr2 driverlayer.IPr2Print, pin *driverlayer.DriverArg) error {
	var pc PrintCurState
	pf, e := ParserPrintXml(s)
	if e != nil {
		utils.Error("parse xml file error %s", e.Error())
	} else {
		utils.Info("parse xml file success")
	}
	ps := pf.S
	pi := pf.V
	pc.BottomMargin = ps.ps.Bottommargin
	pc.LeftMargin = ps.ps.Leftmargin
	pc.PageHeight = ps.ps.Height
	pc.PageWidth = ps.ps.Width
	pc.TopMargin = ps.ps.Topmargin
	pc.RightMargin = ps.ps.Rightmargin
	pc.CurX = 0
	pc.CurY = 0
	pc.CurPage = 1
	pc.Flags = 0
	pc.LineInterval = ps.ps.LineInterval
	pc.ColInterval = ps.ps.ColInterval

	RecurCalcExtent(pi, &pc)
	utils.Info("RecurCalcExtent success")
	fl := GeneratePrintLine(pi)
	utils.Debug("begin print printline----------------------------")
	PrintPrintLine(fl)
	utils.Debug("end print printline----------------------------")
	pr2.BeginPrintJob(pin, 20)
	defer pr2.EndPrinterJob()
	RunRealPrinter(ps, fl, pr2)
	return nil
}
開發者ID:kity-xu,項目名稱:xuxiaodong,代碼行數:34,代碼來源:printrunengine.go


注:本文中的cn/agree/utils.Error函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。