make ffi error structure not found point to the correct culprit

This commit is contained in:
Skgland
2025-08-17 17:35:57 +02:00
committed by Bennet Bleßmann
parent 176858ad42
commit 3b5b768f4a
2 changed files with 111 additions and 163 deletions

View File

@@ -622,13 +622,29 @@ impl MachineState {
FfiError::InvalidArgument => atom!("invalid_argument"),
FfiError::InvalidStruct => atom!("invalid_struct"),
FfiError::FunctionNotFound => atom!("function_not_found"),
FfiError::StructNotFound => atom!("struct_not_found"),
FfiError::StructNotFound(culprit) => {
let stub = functor!(
atom!("ffi_error"),
[
atom_as_cell((atom!("struct_not_found"))),
atom_as_cell(culprit)
]
);
return MachineError {
stub,
location: None,
};
}
FfiError::ArgCountMismatch => atom!("mismatched_argument_count"),
FfiError::AllocationFailed => atom!("allocation_failed"),
FfiError::LayoutError => atom!("layout_error"),
FfiError::UnsupportedAbi => atom!("unsupported_abi"),
};
let stub = functor!(atom!("ffi_error"), [atom_as_cell(error_atom), cell(culprit)]);
let stub = functor!(
atom!("ffi_error"),
[atom_as_cell(error_atom), cell(culprit)]
);
MachineError {
stub,