alef 0.23.39

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
// lastError retrieves the last error from the FFI layer.
func lastError() error {
	code := int32(C.{{ ffi_prefix }}_last_error_code())
	if code == 0 {
		return nil
	}
	ctx := C.{{ ffi_prefix }}_last_error_context()
	if ctx == nil {
		return fmt.Errorf("[%d] native error", code)
	}
	message := C.GoString(ctx)
	return fmt.Errorf("[%d] %s", code, message)
}