(raw: *mut c_char, fallback: &'static str)
| 237 | } |
| 238 | |
| 239 | fn native_error(raw: *mut c_char, fallback: &'static str) -> AppError { |
| 240 | if raw.is_null() { |
| 241 | return AppError::native(fallback); |
| 242 | } |
| 243 | let message = take_native_string(raw); |
| 244 | if message.trim().is_empty() { |
| 245 | AppError::native(fallback) |
| 246 | } else { |
| 247 | AppError::native(message) |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | fn take_native_string(raw: *mut c_char) -> String { |
| 252 | let value = unsafe { CStr::from_ptr(raw).to_string_lossy().into_owned() }; |
no test coverage detected