pedrocr / rawloader

rust library to extract the raw data and some metadata from digital camera images
GNU Lesser General Public License v2.1
304 stars 53 forks source link

Implement std::error::Error for errors #27

Open runfalk opened 4 years ago

runfalk commented 4 years ago

Currently the error type is Err(String) for most (maybe all) operations. This means you can't use this library with something like anyhow.

I've heard good things about thiserror. Maybe that's an alternative?

pedrocr commented 4 years ago

There's already an error type that uses std::error::Error:

https://github.com/pedrocr/rawloader/blob/9c13d5162cc0c6d1740a9fbe5c5a8d5983f05d2b/src/lib.rs#L73-L98

What else would be needed?

runfalk commented 4 years ago

I didn't realise there was such a struct already in place. It should be enough for anyhow. It just requires std::error::Error + Send + Sync + 'static.

I can try to update all places that still use a String and make them use RawLoaderError instead then?

pedrocr commented 4 years ago

Go ahead if you want. The reason I didn't bother was that those are all internal to the crate and so don't affect the API.