diff --git a/crates/lune-std-ffi/src/c/struct_info.rs b/crates/lune-std-ffi/src/c/struct_info.rs index 3abbe73f..9f5b1c98 100644 --- a/crates/lune-std-ffi/src/c/struct_info.rs +++ b/crates/lune-std-ffi/src/c/struct_info.rs @@ -20,12 +20,12 @@ fn get_field_table<'lua>( userdata: &LuaAnyUserData<'lua>, ) -> LuaResult> { let value = association::get(lua, CSTRUCT_INNER, userdata)? - .ok_or_else(|| LuaError::external("Failed to get inner field table. not found"))?; + .ok_or_else(|| LuaError::external("Failed to retrieve inner field table: not found"))?; if let LuaValue::Table(table) = value { Ok(table) } else { Err(LuaError::external( - "Failed to get inner field table. not a table", + "Failed to retrieve inner field: not a table", )) } } diff --git a/crates/lune-std-ffi/src/data/box_data/mod.rs b/crates/lune-std-ffi/src/data/box_data/mod.rs index 4e75b10d..9585a57d 100644 --- a/crates/lune-std-ffi/src/data/box_data/mod.rs +++ b/crates/lune-std-ffi/src/data/box_data/mod.rs @@ -86,7 +86,7 @@ impl BoxData { if let Some(t) = offset { if !bounds.check_boundary(t) { return Err(LuaError::external(format!( - "Offset is out of bounds. box.size: {}. offset got {}", + "Offset out of bounds (box.size: {}, got {})", target.size(), t ))); diff --git a/crates/lune-std-ffi/src/data/ref_data/mod.rs b/crates/lune-std-ffi/src/data/ref_data/mod.rs index 26de8269..d54ab4ba 100644 --- a/crates/lune-std-ffi/src/data/ref_data/mod.rs +++ b/crates/lune-std-ffi/src/data/ref_data/mod.rs @@ -69,12 +69,12 @@ impl RefData { pub unsafe fn deref(&self) -> LuaResult { if !u8_test(self.flags, RefFlag::Dereferenceable.value()) { - return Err(LuaError::external("This pointer is not dereferenceable.")); + return Err(LuaError::external("Reference is not dereferenceable")); } if !self.boundary.check_sized(0, size_of::()) { return Err(LuaError::external( - "Offset is out of bounds. Dereferencing pointer requires size of usize", + "Offset out of bounds", )); } @@ -99,7 +99,7 @@ impl RefData { pub unsafe fn offset(&self, offset: isize) -> LuaResult { u8_test(self.flags, RefFlag::Offsetable.value()) .then_some(()) - .ok_or_else(|| LuaError::external("This pointer is not offsetable."))?; + .ok_or_else(|| LuaError::external("Reference is not offsetable"))?; // Check boundary, if exceed, return error self.boundary @@ -107,7 +107,7 @@ impl RefData { .then_some(()) .ok_or_else(|| { LuaError::external(format!( - "Offset is out of bounds. high: {}, low: {}. offset got {}", + "Offset out of bounds (high: {}, low: {}, got {})", self.boundary.above, self.boundary.below, offset )) })?; diff --git a/crates/lune-std-ffi/src/ffi/libffi_helper.rs b/crates/lune-std-ffi/src/ffi/libffi_helper.rs index 04d764db..c91d2d5f 100644 --- a/crates/lune-std-ffi/src/ffi/libffi_helper.rs +++ b/crates/lune-std-ffi/src/ffi/libffi_helper.rs @@ -17,12 +17,7 @@ pub fn get_ensured_size(ffi_type: *mut raw::ffi_type) -> LuaResult { ) }; - if result != raw::ffi_status_FFI_OK { - return Err(LuaError::external(format!( - "ffi_prep_cif failed. expected result {}, got {}", - FFI_STATUS_NAMES[0], FFI_STATUS_NAMES[result as usize] - ))); - } + ffi_status_assert(result)?; unsafe { Ok((*ffi_type).size) } } diff --git a/crates/lune-std-ffi/src/ffi/mod.rs b/crates/lune-std-ffi/src/ffi/mod.rs index c4fa7d08..7e65f5e2 100644 --- a/crates/lune-std-ffi/src/ffi/mod.rs +++ b/crates/lune-std-ffi/src/ffi/mod.rs @@ -53,7 +53,7 @@ pub trait FfiConvert { _offset: isize, _data_handle: &Ref, ) -> LuaResult { - Err(LuaError::external("stringify not implemented")) + Err(LuaError::external("Stringify method not implemented")) } }