File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,16 @@ pub extern "C" fn get_error() -> *mut c_char {
55
55
}
56
56
}
57
57
58
+ /// # Safety
59
+ /// We check if the pointers are null
60
+ /// This is only used in a test
61
+ #[ no_mangle]
62
+ pub unsafe extern "C" fn set_error ( err : * const c_char ) {
63
+ null_pointer_check ! ( err) ;
64
+ let msg = FfiStr :: from_raw ( err) . into_string ( ) ;
65
+ ffi_helpers:: error_handling:: update_last_error ( anyhow:: anyhow!( msg) ) ;
66
+ }
67
+
58
68
#[ no_mangle]
59
69
pub extern "C" fn clear_error ( ) {
60
70
ffi_helpers:: error_handling:: clear_last_error ( ) ;
Original file line number Diff line number Diff line change @@ -238,8 +238,6 @@ func GetDAError() (err error) {
238
238
if errData != nil {
239
239
defer C .free (unsafe .Pointer (errData ))
240
240
241
- C .clear_error ()
242
-
243
241
errStr := C .GoString (errData )
244
242
return fmt .Errorf ("NEAR DA client %s" , errStr )
245
243
} else {
Original file line number Diff line number Diff line change @@ -162,7 +162,6 @@ func TestTo32Bytes(t *testing.T) {
162
162
163
163
func TestGetDAError (t * testing.T ) {
164
164
// Test error case
165
- // TODO: Mock the C.get_error function to return an error
166
165
near .TestSetError ("test error" )
167
166
err := near .GetDAError ()
168
167
assert .Error (t , err )
You can’t perform that action at this time.
0 commit comments