ros2_rust icon indicating copy to clipboard operation
ros2_rust copied to clipboard

Use thiserror for RclrsError

Open mxgrey opened this issue 6 months ago • 2 comments

Currently we're implementing Error for RclrsError manually which isn't best practice. The thiserror crate makes it very convenient to implement the standard Error trait and helps keep the implementation correct.

I'm opening this issue as a self-reminder, maintainers can feel free to assign this ticket to me.

mxgrey avatar May 14 '25 08:05 mxgrey

I was going to do this after an earlier PR, but I then found https://github.com/dtolnay/thiserror/issues/245. I quite liked having the doccomments, and I meant to investigate further but never did.

I did another quick search just now and found this: https://github.com/dtolnay/thiserror/issues/44. That library looks interesting, but would be yet another dependency

alluring-mushroom avatar May 19 '25 23:05 alluring-mushroom

Interesting... I do like the idea of not duplicating the doc comments and the error attribute. The example that combines displaydoc and thiserror looks very sensible.

I'll give that a try when I get around to tackling this issue. Or you're very welcome to make a PR if that's something you were already planning to do, since it may be a while yet before I can get around to this.

mxgrey avatar May 20 '25 05:05 mxgrey