Simplify the errors in native.go and make them more descriptive

This commit is contained in:
rhl120 authored and pancake committed 2022-06-17 20:12:22 +02:00
1 parent 2e9d80edb3
commit f87fd79670
1 file changed
+3 -2
+3 -2
View File
@@ -73,14 +73,15 @@ func dlOpen(path string) (*DL, error) {
}
func dlSym(dl *DL, name string) (unsafe.Pointer, error) {
err := fmt.Errorf("Failed to load '%s' from '%s'", name, dl.name)
cname := C.CString(name)
if cname == nil {
return nil, errors.New("Fail")
return nil, errors.New(err)
}
handle := C.dlsym(dl.handle, cname)
C.free(unsafe.Pointer(cname))
if handle == nil {
return nil, errors.New("Fail")
return nil, errors.New(err)
}
return handle, nil
}