As I start I would recommend you not using .map_err to return a String. I’d make my own Error enum and have it implement Display (and maybe Debug as well) for such cases.
Or, even better, just implement rustler’s Encoder for it and map it to error tuples.
(Still use .map_err though, that’s how it’s done when you want to use ? and return Result-s but need your own custom error and want it serialized as an Elixir value.)
Or all of the above. I am doing that in my library (dimitarvp/xqlite on GitHub). Could send you a small PR if I have the time, though that’s not very likely, admittedly.






















