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

@ -90,8 +90,8 @@ struct ClientTests {
do {
try await client.connect(transport: transport)
#expect(Bool(false), "Expected connection to fail")
} catch let error as Error {
if case Error.transportError = error {
} catch let error as MCPError {
if case MCPError.transportError = error {
#expect(Bool(true))
} else {
#expect(Bool(false), "Expected transport error")
@ -112,8 +112,8 @@ struct ClientTests {
do {
try await client.ping()
#expect(Bool(false), "Expected ping to fail")
} catch let error as Error {
if case Error.transportError = error {
} catch let error as MCPError {
if case MCPError.transportError = error {
#expect(Bool(true))
} else {
#expect(Bool(false), "Expected transport error")
@ -132,12 +132,12 @@ struct ClientTests {
try await client.connect(transport: transport)
// Create a task for listPrompts
let promptsTask = Task<Void, Swift.Error> {
let promptsTask = Task<Void, Error> {
do {
_ = try await client.listPrompts()
#expect(Bool(false), "Expected listPrompts to fail in strict mode")
} catch let error as Error {
if case Error.methodNotFound = error {
} catch let error as MCPError {
if case MCPError.methodNotFound = error {
#expect(Bool(true))
} else {
#expect(Bool(false), "Expected methodNotFound error, got \(error)")
@ -185,7 +185,7 @@ struct ClientTests {
// Create an error response with the same ID
let errorResponse = Response<ListPrompts>(
id: decodedRequest.id,
error: Error.methodNotFound("Test: Prompts capability not available")
error: MCPError.methodNotFound("Test: Prompts capability not available")
)
try await transport.queue(response: errorResponse)
@ -193,8 +193,8 @@ struct ClientTests {
do {
_ = try await client.listPrompts()
#expect(Bool(false), "Expected listPrompts to fail in non-strict mode")
} catch let error as Error {
if case Error.methodNotFound = error {
} catch let error as MCPError {
if case MCPError.methodNotFound = error {
#expect(Bool(true))
} else {
#expect(Bool(false), "Expected methodNotFound error, got \(error)")