MWATelescope / mwalib

Library to read Murchison Widefield Array (MWA) raw visibilities, voltages and metadata into a common structure
Mozilla Public License 2.0
10 stars 2 forks source link

Improved FFI error handling #51

Open gsleap opened 2 years ago

gsleap commented 2 years ago

From Chris Jordan: "I've recently stumbled upon this guide for error handling: https://michael-f-bryan.github.io/rust-ffi-guide/errors/return_types.html This makes things much cleaner by having mwalib track the last error and the caller allocates their own string to display it if they want to. Right now, mwalib FFI callers are allocating an error string length which could be overflowed (this is pedantic, but I think it's nice to have a loose end removed) and providing two extra arguments to every function. It's also possible to handle panics better (which aren't handled at all right now). I've been working on doing all this kinda thing through hyperbeam, let me know if you wanna chat about it."