mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 17:48:29 +08:00
36 lines
916 B
Go
36 lines
916 B
Go
package querynode
|
|
|
|
/*
|
|
#cgo CFLAGS: -I${SRCDIR}/../core/output/include
|
|
#cgo LDFLAGS: -L${SRCDIR}/../core/output/lib -lmilvus_segcore -Wl,-rpath=${SRCDIR}/../core/output/lib
|
|
|
|
#include <malloc.h>
|
|
#include "common/type_c.h"
|
|
*/
|
|
import "C"
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"github.com/zilliztech/milvus-distributed/internal/log"
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
|
"unsafe"
|
|
)
|
|
|
|
func HandleCStatus(status *C.CStatus, extraInfo string) error {
|
|
if status.error_code == 0 {
|
|
return nil
|
|
}
|
|
errorCode := status.error_code
|
|
errorName, ok := commonpb.ErrorCode_name[int32(errorCode)]
|
|
if !ok {
|
|
errorName = "UnknownError"
|
|
}
|
|
errorMsg := C.GoString(status.error_msg)
|
|
defer C.free(unsafe.Pointer(status.error_msg))
|
|
|
|
finalMsg := fmt.Sprintf("[%s] %s", errorName, errorMsg)
|
|
logMsg := fmt.Sprintf("%s, C Runtime Exception: %s\n", extraInfo, finalMsg)
|
|
log.Error(logMsg)
|
|
return errors.New(finalMsg)
|
|
}
|