rawloader icon indicating copy to clipboard operation
rawloader copied to clipboard

Implement std::error::Error for errors

Open runfalk opened this issue 5 years ago • 3 comments

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?

runfalk avatar Jan 21 '20 14:01 runfalk

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?

pedrocr avatar Jan 21 '20 14:01 pedrocr

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?

runfalk avatar Jan 21 '20 19:01 runfalk

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.

pedrocr avatar Feb 01 '20 17:02 pedrocr