Skip to content

Commit

Permalink
Add Error::method to set a custom error message
Browse files Browse the repository at this point in the history
This enables updating the message without creating a binding.
  • Loading branch information
ModProg committed Jan 14, 2024
1 parent a27868b commit 3be3a14
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/jsonrpc/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ impl Error {
pub const fn content_modified() -> Self {
Error::new(ErrorCode::ContentModified)
}

/// Sets a custom `message`.
pub const fn message<M>(mut self, message: M) -> Self
where
M: Into<Cow<'static, str>>,
{
self.message = message.into();
self
}
}

impl Display for Error {
Expand Down

0 comments on commit 3be3a14

Please sign in to comment.