Crates.io | error-doc |
lib.rs | error-doc |
version | 0.2.0 |
source | src |
created_at | 2024-08-17 17:38:40.825074 |
updated_at | 2024-08-21 18:17:24.338041 |
description | A simple proc macro to generate #[doc] comments from #[error] messages |
homepage | |
repository | https://codeberg.org/supnas/error-doc |
max_upload_size | |
id | 1341881 |
size | 3,725 |
A simple proc macro to generate #[doc]
comments from #[error]
messages
The errors
macro derives thiserror::Error
and core::fmt::Debug
traits, and automatically generates missing documents for error variants from error messages.
Using error_doc
macro, you can also derive Error
and Debug
trait separately.
#[error_doc::errors]
pub enum SomeError {
#[error("failed to open config file")]
OpenFile(#[from] std::io::Error),
#[error(transparent)]
#[doc = "Database error"]
Database(#[from] sqlx::Error),
#[error("unexpected value: `{0}`")]
#[doc = "Unexpected value is provided"]
UnexpectedValue(u16),
#[error("some other error")]
Other,
}
and
#[error_doc::error_doc]
#[derive(thiserror::Error, Debug)]
pub enum SomeError {
#[error("failed to open config file")]
OpenFile(#[from] std::io::Error),
#[error(transparent)]
#[doc = "Database error"]
Database(#[from] sqlx::Error),
#[error("unexpected value: `{0}`")]
#[doc = "Unexpected value is provided"]
UnexpectedValue(u16),
#[error("some other error")]
Other,
}
generates
#[derive(thiserror::Error, Debug)]
pub enum SomeError {
#[error("failed to open config file")]
#[doc = "Failed to open config file"]
OpenFile(#[from] std::io::Error),
#[error(transparent)]
#[doc = "Database error"]
Database(#[from] sqlx::Error),
#[error("unexpected value: `{0}`")]
#[doc = "Unexpected value is provided"]
UnexpectedValue(u16),
#[error("some other error")]
#[doc = "Some other error"]
Other,
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.