Exemplo n.º 1
0
func (this *MqS) ErrorSet(ex interface{}) {
	if ctx, ok := ex.(*MqSException); ok {
		C.MqErrorCopy((*_Ctype_struct_MqS)(this), (*_Ctype_struct_MqS)(ctx))
	} else if err, ok := ex.(os.Error); ok {
		m := C.CString(err.String())
		C.MqErrorC((*_Ctype_struct_MqS)(this), C.sERROR, -1, m)
		C.free(unsafe.Pointer(m))
	} else if err, ok := ex.(fmt.Stringer); ok {
		m := C.CString(err.String())
		C.MqErrorC((*_Ctype_struct_MqS)(this), C.sERROR, -1, m)
		C.free(unsafe.Pointer(m))
	} else {
		m := C.CString(fmt.Sprintf("%s", ex))
		C.MqErrorC((*_Ctype_struct_MqS)(this), C.sERROR, -1, m)
		C.free(unsafe.Pointer(m))
	}
	/*
	   // add stack-trace
	   for i:=4; i<5; i++ {
	     _,file,line,ok := runtime.Caller(i)
	     if !ok { break }
	     s := C.CString(fmt.Sprintf("called from %s(%d)", file, line))
	       C.MqErrorSAppendC((*_Ctype_struct_MqS)(this), s)
	     C.free(unsafe.Pointer(s))
	   }
	*/
}
Exemplo n.º 2
0
func (this *MqS) ErrorC(prefix string, level int32, message string) {
	p := C.CString(prefix)
	m := C.CString(message)
	C.MqErrorC((*_Ctype_struct_MqS)(this), p, C.MQ_INT(level), m)
	C.free(unsafe.Pointer(p))
	C.free(unsafe.Pointer(m))
}