Defer error codes to a field in derive macro
I like doing custom errors with a kind field (usually an enum) to describe the exact type of error, kinda like std::io::Error with its ErrorKind. For labels and help, it's easy to just refer to that field. But from what I see in the docs, there's no way to do the same for code when using the derive macro. Would be nice if that worked, right now I have to implement Diagnostic manually just because of that.
I'm up for adding support for it myself, just need to know what the preferred syntax would be.
Hmmm. forward or transparent might be an option and might be the more idiomatic approach? https://github.com/zkat/miette?tab=readme-ov-file#-in-libraries
Otherwise, bikeshedding
#[diagnostic_code]
I don't have an opinion on whether or not this should be supported (in most cases I think it's probably not needed, but then again, it's not like it's gonna stop you from reusing the same code in multiple error types anyway, so blocking it doesn't seem like it adds a ton of value). Just bikeshedding.
The most freeing option would be to define a method or something inline. So that you can define #[code = self.some_method()] or #[code = self.kind.code()]. But we would still need syntax to allow that as the assignment is already taken.