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:
parent
a9bcbf9ad9
commit
09da2a1c01
1 changed files with 108 additions and 88 deletions
|
|
@ -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)")
|
||||
|
|
|
|||
Loading…
Reference in a new issue