mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Improve FFI error message handling
This commit is contained in:
+3
-2
@@ -16,8 +16,9 @@ use crate::state::{plugin_crc, plugin_version};
|
||||
|
||||
pub(crate) fn error(code: c_int, message: &str) -> c_int {
|
||||
ERROR_MESSAGE.with(|f| {
|
||||
*f.borrow_mut() =
|
||||
CString::new(message.as_bytes()).unwrap_or(c"Failed to retrieve error message".into());
|
||||
*f.borrow_mut() = CString::new(message.as_bytes())
|
||||
.or_else(|_e| CString::new(message.replace('\0', "\\0").as_bytes()))
|
||||
.unwrap_or_else(|_e| c"Failed to retrieve error message".into());
|
||||
});
|
||||
code
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user