[solved] What are the various Error Handling mechanisms in Rust?

Except that try! is a huge pain in any sufficiently complicated expression where each part can potentially fail, which is what my point was. :stuck_out_tongue:

I think the disconnect is that I'm thinking about (having written a few) cases where you have things like checked arithmetic which, even with a try!-alike are just horrible in Rust. I'm no longer convinced the OP was thinking about the same thing.

As far as I can see arrayfire performs runtime checks to make sure that array arguments have the right dimensions and if they contain floating points. This works well in C and C++, but it doesn't work well in rust, because it forces you to do a lot of error handling.

It might be possible to introduce specialized wrappers for Dim4 so that the compiler can distinguish between vectors and matrices at compile time, making some of the error handling unneccesary. I don't have a lot of experience with wrapping C-code, so others may give better advice here.

Also have a look at blusses very nice rust-ndarray. https://github.com/bluss/rust-ndarray

In this case I would just panic in the arithmetic functions themselves. Do you have many situations where you need to recover when that kind of mistake has occurred?

@jamougha Sure, that was one of our internal suggestions as well - to panic during arithmetic operations (when operators are used). Hm, i can't think of any production time scenarios where this can happen other than while writing the module itself due to programmer err.
-- On second thought, this could happen due to incorrect inputs.

@nielsle Sure, will look at rust-ndarray.