Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'lib/lsp-server/src/error.rs')
| -rw-r--r-- | lib/lsp-server/src/error.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/lsp-server/src/error.rs b/lib/lsp-server/src/error.rs index 755b3fd959..ebdd153b5b 100644 --- a/lib/lsp-server/src/error.rs +++ b/lib/lsp-server/src/error.rs @@ -3,7 +3,22 @@ use std::fmt; use crate::{Notification, Request}; #[derive(Debug, Clone, PartialEq)] -pub struct ProtocolError(pub(crate) String); +pub struct ProtocolError(String, bool); + +impl ProtocolError { + pub(crate) fn new(msg: impl Into<String>) -> Self { + ProtocolError(msg.into(), false) + } + + pub(crate) fn disconnected() -> ProtocolError { + ProtocolError("disconnected channel".into(), true) + } + + /// Whether this error occured due to a disconnected channel. + pub fn channel_is_disconnected(&self) -> bool { + self.1 + } +} impl std::error::Error for ProtocolError {} |