2024-06-09 14:55:53 +00:00
|
|
|
package cgo
|
|
|
|
|
|
|
|
/*
|
2024-08-23 04:35:02 +00:00
|
|
|
#cgo pkg-config: milvus_core
|
2024-06-09 14:55:53 +00:00
|
|
|
|
|
|
|
#include "common/type_c.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/merr"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ConsumeCStatusIntoError(status *C.CStatus) error {
|
|
|
|
if status.error_code == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
errorCode := status.error_code
|
|
|
|
errorMsg := C.GoString(status.error_msg)
|
|
|
|
getCGOCaller().call("free", func() {
|
|
|
|
C.free(unsafe.Pointer(status.error_msg))
|
|
|
|
})
|
|
|
|
return merr.SegcoreError(int32(errorCode), errorMsg)
|
|
|
|
}
|