Skip to content

Commit f39b909

Browse files
committed
Convert special NSError to CancellationError
1 parent cbe3ab2 commit f39b909

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Core/Sources/Client/AsyncXPCService.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ struct AutoFinishContinuation<T> {
180180
}
181181

182182
func reject(_ error: Error) {
183-
continuation.finish(throwing: error)
183+
if (error as NSError).code == -100 {
184+
continuation.finish(throwing: CancellationError())
185+
} else {
186+
continuation.finish(throwing: error)
187+
}
184188
}
185189
}
186190

Core/Sources/Service/Helpers.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ extension NSError {
8888
NSLocalizedDescriptionKey: message,
8989
])
9090
}
91+
if let error = error as? CancellationError {
92+
return NSError(domain: "com.intii.CopilotForXcode", code: -100, userInfo: [
93+
NSLocalizedDescriptionKey: error.localizedDescription,
94+
])
95+
}
9196
return NSError(domain: "com.intii.CopilotForXcode", code: -1, userInfo: [
9297
NSLocalizedDescriptionKey: error.localizedDescription,
9398
])

0 commit comments

Comments
 (0)