-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
49 additions
and
83 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,30 @@ | ||
use std::io; | ||
|
||
use crossbeam_channel::SendError; | ||
use lsp_server::{ExtractError, Message}; | ||
use thiserror::Error; | ||
|
||
/// 自定义错误,兼容项目错误内容 | ||
#[derive(Debug, Error, miette::Diagnostic)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
#[diagnostic(code(lsp::server_capabilities))] | ||
ServerCapabilities(#[from] serde_json::Error), | ||
|
||
#[error(transparent)] | ||
#[diagnostic(code(lsp::server_init))] | ||
ServerInit(#[from] lsp_server::ProtocolError), | ||
|
||
#[error(transparent)] | ||
#[diagnostic(code(lsp::io))] | ||
Io(#[from] io::Error), | ||
|
||
#[error("Unsupported LSP request: {request}")] | ||
#[diagnostic(code(lsp::unsupported_lsp_request))] | ||
UnsupportedLspRequest { request: String }, | ||
|
||
#[error(transparent)] | ||
#[diagnostic(code(lsp::cast_request))] | ||
CastRequest(#[from] ExtractError<lsp_server::Request>), | ||
|
||
#[error(transparent)] | ||
#[diagnostic(code(lsp::cast_notification))] | ||
CastNotification(#[from] ExtractError<lsp_server::Notification>), | ||
|
||
#[error(transparent)] | ||
#[diagnostic(code(lsp::send))] | ||
Send(#[from] SendError<Message>), | ||
|
||
#[error(transparent)] | ||
#[diagnostic(code(lsp::send))] | ||
PathToUri(#[from] url::ParseError), | ||
#[error("position {0}:{1} is out of bounds")] | ||
PositionOutOfBounds(u32, u32), | ||
|
||
#[error(transparent)] | ||
Aho(#[from] aho_corasick::BuildError), | ||
#[error("clipboard provider: stdin is missing")] | ||
ClipboardMissStdin, | ||
|
||
#[error(transparent)] | ||
#[diagnostic(code(lsp::log))] | ||
Logger(#[from] flexi_logger::FlexiLoggerError), | ||
#[error("clipboard provider: stdout is missing")] | ||
ClipboardMissStdout, | ||
|
||
#[error("position {0}:{1} is out of bounds")] | ||
PositionOutOfBounds(u32, u32), | ||
#[error("clipboard provider {0} failed")] | ||
ClipboardFail(&'static str), | ||
|
||
#[error("Not Found: {0}")] | ||
NotFound(String), | ||
// #[error("unknown data store error")] | ||
// Unknown, | ||
} | ||
|
||
impl<T> From<Error> for crate::Result<T> { | ||
fn from(val: Error) -> Self { | ||
Err(Box::new(val)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters