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 Feb 27, 2024
1 parent a27868b commit 531b2af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "tower-lsp"
version = "0.20.0"
authors = ["Eyal Kalderon <[email protected]>"]
edition = "2021"
rust-version = "1.65.0"
rust-version = "1.64.0"
description = "Language Server Protocol implementation based on Tower"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/ebkalderon/tower-lsp"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.65.0
1.64.0
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 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 531b2af

Please sign in to comment.