Rename Error to MCPError (#44)

* Rename Error to MCPError

* Conform MCPError to Swift.Error

* Use unqualified Error instead of Swift.Error

* Use unqualified MCPError instead of MCP.MCPError

* Rename file back to Error.swift

* Introduce top-level MCP namespace with nested Error typealias to provide deprecation notice for existing usage of MCP.Error

* Fix markup for MCP enum warning
This commit is contained in:
Mattt 2025-04-03 05:25:00 -07:00 • committed by GitHub
commit 09da2a1c01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,7 +60,7 @@ extension Method {
}
/// Create a response with the given error.
public static func response(id: ID, error: Error) -> Response<Self> {
public static func response(id: ID, error: MCPError) -> Response<Self> {
Response(id: id, error: error)
}
}
@ -186,14 +186,14 @@ public struct Response<M: Method>: Hashable, Identifiable, Codable, Sendable {
/// The response ID.
public let id: ID
/// The response result.
public let result: Swift.Result<M.Result, Error>
public let result: Swift.Result<M.Result, MCPError>
public init(id: ID, result: M.Result) {
self.id = id
self.result = .success(result)
}
public init(id: ID, error: Error) {
public init(id: ID, error: MCPError) {
self.id = id
self.result = .failure(error)
}
@ -224,7 +224,7 @@ public struct Response<M: Method>: Hashable, Identifiable, Codable, Sendable {
id = try container.decode(ID.self, forKey: .id)
if let result = try? container.decode(M.Result.self, forKey: .result) {
self.result = .success(result)
} else if let error = try? container.decode(Error.self, forKey: .error) {
} else if let error = try? container.decode(MCPError.self, forKey: .error) {
self.result = .failure(error)
} else {
throw DecodingError.dataCorrupted(