1use rmcp::model::ErrorData;
2
3#[derive(Debug, thiserror::Error)]
4pub enum McpGithubError {
5 #[error("GitHub API error: {0}")]
6 GitHub(#[from] octocrab::Error),
7
8 #[error("Missing required parameter: {0}")]
9 MissingParam(String),
10
11 #[error("Repository not found: {0}")]
12 RepoNotFound(String),
13
14 #[error("Authentication required")]
15 Unauthenticated,
16
17 #[error("{0}")]
18 Other(String),
19}
20
21impl McpGithubError {
22 pub fn to_mcp_error(&self) -> ErrorData {
23 match self {
24 McpGithubError::MissingParam(_) | McpGithubError::RepoNotFound(_) => {
25 ErrorData::invalid_params(self.to_string(), None)
26 }
27 McpGithubError::Unauthenticated => {
28 ErrorData::invalid_params(self.to_string(), None)
29 }
30 McpGithubError::GitHub(_) | McpGithubError::Other(_) => {
31 ErrorData::internal_error(self.to_string(), None)
32 }
33 }
34 }
35}