Add an XCTestError struct.

This is to match the struct generated by the Objective-C importer for
Apple XCTest due to its XCTestErrorCode having been marked with the
NSErrorDomain API note.
diff --git a/Sources/XCTest/Public/Asynchronous/XCTestCase+Asynchronous.swift b/Sources/XCTest/Public/Asynchronous/XCTestCase+Asynchronous.swift
index 5c17983..0b33b0f 100644
--- a/Sources/XCTest/Public/Asynchronous/XCTestCase+Asynchronous.swift
+++ b/Sources/XCTest/Public/Asynchronous/XCTestCase+Asynchronous.swift
@@ -139,7 +139,7 @@
                 // If the test failed, send an error object.
                 error = NSError(
                     domain: XCTestErrorDomain,
-                    code: XCTestErrorCode.timeoutWhileWaiting.rawValue,
+                    code: XCTestError.Code.timeoutWhileWaiting.rawValue,
                     userInfo: [:])
             }
             completionHandler(error)
diff --git a/Sources/XCTest/Public/XCTestErrors.swift b/Sources/XCTest/Public/XCTestErrors.swift
index e4b7a94..18014a4 100644
--- a/Sources/XCTest/Public/XCTestErrors.swift
+++ b/Sources/XCTest/Public/XCTestErrors.swift
@@ -14,14 +14,32 @@
 /// The domain used by errors produced by the XCTest library.
 public let XCTestErrorDomain = "org.swift.XCTestErrorDomain"
 
-/// Error codes for errors in the XCTestErrorDomain.
-public enum XCTestErrorCode : Int {
+/// Describes an error in the XCTestErrorDomain.
+public struct XCTestError : _BridgedStoredNSError {
+    public let _nsError: NSError
+
+    public init(_nsError error: NSError) {
+        precondition(error.domain == XCTestErrorDomain)
+        self._nsError = error
+    }
+
+    public static var _nsErrorDomain: String { return XCTestErrorDomain }
+
+    public enum Code : Int, _ErrorCodeProtocol {
+        public typealias _ErrorType = XCTestError
+
+        case timeoutWhileWaiting
+        case failureWhileWaiting
+    }
+}
+
+public extension XCTestError {
     /// Indicates that one or more expectations failed to be fulfilled in time
     /// during a call to `waitForExpectations(timeout:handler:)`
-    case timeoutWhileWaiting
+    public static var timeoutWhileWaiting: XCTestError.Code { return .timeoutWhileWaiting }
 
     /// Indicates that a test assertion failed while waiting for expectations
     /// during a call to `waitForExpectations(timeout:handler:)`
     /// FIXME: swift-corelibs-xctest does not currently produce this error code.
-    case failureWhileWaiting
+    public static var failureWhileWaiting: XCTestError.Code { return .failureWhileWaiting }
 }
diff --git a/Tests/Functional/Asynchronous/Handler/main.swift b/Tests/Functional/Asynchronous/Handler/main.swift
index 049298c..9be5f0e 100644
--- a/Tests/Functional/Asynchronous/Handler/main.swift
+++ b/Tests/Functional/Asynchronous/Handler/main.swift
@@ -23,7 +23,7 @@
         self.waitForExpectations(timeout: 0.2) { error in
             XCTAssertNotNil(error, "Expectation handlers for unfulfilled expectations should not be nil.")
             XCTAssertEqual(error?.domain, XCTestErrorDomain, "The error domain should be XCTest's own error domain")
-            XCTAssertEqual(error?.code, XCTestErrorCode.timeoutWhileWaiting.rawValue, "The error code should indicate that a timeout occurred")
+            XCTAssertEqual(error?.code, XCTestError.Code.timeoutWhileWaiting.rawValue, "The error code should indicate that a timeout occurred")
             handlerWasCalled = true
         }
         XCTAssertTrue(handlerWasCalled)