   }
 }
 
-public extension NSCocoaError {
+public extension CocoaError {
   private var _userInfo: [NSObject : AnyObject] {
     return (self as NSError).userInfo
   }

  return lhs._nsError.isEqual(rhs._nsError)
}

/// Describes errors within the Cocoa error domain.
public struct NSCocoaError : _BridgedStoredNSError {
  public let _nsError: NSError

  public init(_nsError error: NSError) {

  }
}

extension CocoaError.Code {
  public static var fileNoSuchFileError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4)
  }
  public static var fileLockingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 255)
  }
  public static var fileReadUnknownError: CocoaError.Code {
    return CocoaError.Code(rawValue: 256)
  }
  public static var fileReadNoPermissionError: CocoaError.Code {
    return CocoaError.Code(rawValue: 257)
  }
  public static var fileReadInvalidFileNameError: CocoaError.Code {
    return CocoaError.Code(rawValue: 258)
  }
  public static var fileReadCorruptFileError: CocoaError.Code {
    return CocoaError.Code(rawValue: 259)
  }
  public static var fileReadNoSuchFileError: CocoaError.Code {
    return CocoaError.Code(rawValue: 260)
  }
  public static var fileReadInapplicableStringEncodingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 261)
  }
  public static var fileReadUnsupportedSchemeError: CocoaError.Code {
    return CocoaError.Code(rawValue: 262)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var fileReadTooLargeError: CocoaError.Code {
    return CocoaError.Code(rawValue: 263)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var fileReadUnknownStringEncodingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 264)
  }

  public static var fileWriteUnknownError: CocoaError.Code {
    return CocoaError.Code(rawValue: 512)
  }
  public static var fileWriteNoPermissionError: CocoaError.Code {
    return CocoaError.Code(rawValue: 513)
  }
  public static var fileWriteInvalidFileNameError: CocoaError.Code {
    return CocoaError.Code(rawValue: 514)
  }

  @available(OSX, introduced: 10.7) @available(iOS, introduced: 5.0)
  public static var fileWriteFileExistsError: CocoaError.Code {
    return CocoaError.Code(rawValue: 516)
  }

  public static var fileWriteInapplicableStringEncodingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 517)
  }
  public static var fileWriteUnsupportedSchemeError: CocoaError.Code {
    return CocoaError.Code(rawValue: 518)
  }
  public static var fileWriteOutOfSpaceError: CocoaError.Code {
    return CocoaError.Code(rawValue: 640)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var fileWriteVolumeReadOnlyError: CocoaError.Code {
    return CocoaError.Code(rawValue: 642)
  }

  @available(OSX, introduced: 10.11) @available(iOS, unavailable)
  public static var fileManagerUnmountUnknownError: CocoaError.Code {
    return CocoaError.Code(rawValue: 768)
  }

  @available(OSX, introduced: 10.11) @available(iOS, unavailable)
  public static var fileManagerUnmountBusyError: CocoaError.Code {
    return CocoaError.Code(rawValue: 769)
  }

  public static var keyValueValidationError: CocoaError.Code {
    return CocoaError.Code(rawValue: 1024)
  }
  public static var formattingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 2048)
  }
  public static var userCancelledError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3072)
  }

  @available(OSX, introduced: 10.8) @available(iOS, introduced: 6.0)
  public static var featureUnsupportedError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3328)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableNotLoadableError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3584)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableArchitectureMismatchError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3585)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableRuntimeMismatchError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3586)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableLoadError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3587)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableLinkError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3588)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var propertyListReadCorruptError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3840)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var propertyListReadUnknownVersionError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3841)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var propertyListReadStreamError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3842)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var propertyListWriteStreamError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3851)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var propertyListWriteInvalidError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3852)
  }

  @available(OSX, introduced: 10.8) @available(iOS, introduced: 6.0)
  public static var xpcConnectionInterrupted: CocoaError.Code {
    return CocoaError.Code(rawValue: 4097)
  }

  @available(OSX, introduced: 10.8) @available(iOS, introduced: 6.0)
  public static var xpcConnectionInvalid: CocoaError.Code {
    return CocoaError.Code(rawValue: 4099)
  }

  @available(OSX, introduced: 10.8) @available(iOS, introduced: 6.0)
  public static var xpcConnectionReplyInvalid: CocoaError.Code {
    return CocoaError.Code(rawValue: 4101)
  }

  @available(OSX, introduced: 10.9) @available(iOS, introduced: 7.0)
  public static var ubiquitousFileUnavailableError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4353)
  }

  @available(OSX, introduced: 10.9) @available(iOS, introduced: 7.0)
  public static var ubiquitousFileNotUploadedDueToQuotaError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4354)
  }

  @available(OSX, introduced: 10.9) @available(iOS, introduced: 7.0)
  public static var ubiquitousFileUbiquityServerNotAvailable: CocoaError.Code {
    return CocoaError.Code(rawValue: 4355)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var userActivityHandoffFailedError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4608)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var userActivityConnectionUnavailableError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4609)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var userActivityRemoteApplicationTimedOutError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4610)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var userActivityHandoffUserInfoTooLargeError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4611)
  }

  @available(OSX, introduced: 10.11) @available(iOS, introduced: 9.0)
  public static var coderReadCorruptError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4864)
  }

  @available(OSX, introduced: 10.11) @available(iOS, introduced: 9.0)
  public static var coderValueNotFoundError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4865)
  }
}

extension CocoaError {
  public static var fileNoSuchFileError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4)
  }
  public static var fileLockingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 255)
  }
  public static var fileReadUnknownError: CocoaError.Code {
    return CocoaError.Code(rawValue: 256)
  }
  public static var fileReadNoPermissionError: CocoaError.Code {
    return CocoaError.Code(rawValue: 257)
  }
  public static var fileReadInvalidFileNameError: CocoaError.Code {
    return CocoaError.Code(rawValue: 258)
  }
  public static var fileReadCorruptFileError: CocoaError.Code {
    return CocoaError.Code(rawValue: 259)
  }
  public static var fileReadNoSuchFileError: CocoaError.Code {
    return CocoaError.Code(rawValue: 260)
  }
  public static var fileReadInapplicableStringEncodingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 261)
  }
  public static var fileReadUnsupportedSchemeError: CocoaError.Code {
    return CocoaError.Code(rawValue: 262)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var fileReadTooLargeError: CocoaError.Code {
    return CocoaError.Code(rawValue: 263)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var fileReadUnknownStringEncodingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 264)
  }

  public static var fileWriteUnknownError: CocoaError.Code {
    return CocoaError.Code(rawValue: 512)
  }
  public static var fileWriteNoPermissionError: CocoaError.Code {
    return CocoaError.Code(rawValue: 513)
  }
  public static var fileWriteInvalidFileNameError: CocoaError.Code {
    return CocoaError.Code(rawValue: 514)
  }

  @available(OSX, introduced: 10.7) @available(iOS, introduced: 5.0)
  public static var fileWriteFileExistsError: CocoaError.Code {
    return CocoaError.Code(rawValue: 516)
  }

  public static var fileWriteInapplicableStringEncodingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 517)
  }
  public static var fileWriteUnsupportedSchemeError: CocoaError.Code {
    return CocoaError.Code(rawValue: 518)
  }
  public static var fileWriteOutOfSpaceError: CocoaError.Code {
    return CocoaError.Code(rawValue: 640)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var fileWriteVolumeReadOnlyError: CocoaError.Code {
    return CocoaError.Code(rawValue: 642)
  }

  @available(OSX, introduced: 10.11) @available(iOS, unavailable)
  public static var fileManagerUnmountUnknownError: CocoaError.Code {
    return CocoaError.Code(rawValue: 768)
  }

  @available(OSX, introduced: 10.11) @available(iOS, unavailable)
  public static var fileManagerUnmountBusyError: CocoaError.Code {
    return CocoaError.Code(rawValue: 769)
  }

  public static var keyValueValidationError: CocoaError.Code {
    return CocoaError.Code(rawValue: 1024)
  }
  public static var formattingError: CocoaError.Code {
    return CocoaError.Code(rawValue: 2048)
  }
  public static var userCancelledError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3072)
  }

  @available(OSX, introduced: 10.8) @available(iOS, introduced: 6.0)
  public static var featureUnsupportedError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3328)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableNotLoadableError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3584)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableArchitectureMismatchError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3585)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableRuntimeMismatchError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3586)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableLoadError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3587)
  }

  @available(OSX, introduced: 10.5) @available(iOS, introduced: 2.0)
  public static var executableLinkError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3588)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var propertyListReadCorruptError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3840)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var propertyListReadUnknownVersionError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3841)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var propertyListReadStreamError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3842)
  }

  @available(OSX, introduced: 10.6) @available(iOS, introduced: 4.0)
  public static var propertyListWriteStreamError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3851)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var propertyListWriteInvalidError: CocoaError.Code {
    return CocoaError.Code(rawValue: 3852)
  }

  @available(OSX, introduced: 10.8) @available(iOS, introduced: 6.0)
  public static var xpcConnectionInterrupted: CocoaError.Code {
    return CocoaError.Code(rawValue: 4097)
  }

  @available(OSX, introduced: 10.8) @available(iOS, introduced: 6.0)
  public static var xpcConnectionInvalid: CocoaError.Code {
    return CocoaError.Code(rawValue: 4099)
  }

  @available(OSX, introduced: 10.8) @available(iOS, introduced: 6.0)
  public static var xpcConnectionReplyInvalid: CocoaError.Code {
    return CocoaError.Code(rawValue: 4101)
  }

  @available(OSX, introduced: 10.9) @available(iOS, introduced: 7.0)
  public static var ubiquitousFileUnavailableError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4353)
  }

  @available(OSX, introduced: 10.9) @available(iOS, introduced: 7.0)
  public static var ubiquitousFileNotUploadedDueToQuotaError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4354)
  }

  @available(OSX, introduced: 10.9) @available(iOS, introduced: 7.0)
  public static var ubiquitousFileUbiquityServerNotAvailable: CocoaError.Code {
    return CocoaError.Code(rawValue: 4355)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var userActivityHandoffFailedError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4608)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var userActivityConnectionUnavailableError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4609)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var userActivityRemoteApplicationTimedOutError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4610)
  }

  @available(OSX, introduced: 10.10) @available(iOS, introduced: 8.0)
  public static var userActivityHandoffUserInfoTooLargeError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4611)
  }

  @available(OSX, introduced: 10.11) @available(iOS, introduced: 9.0)
  public static var coderReadCorruptError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4864)
  }

  @available(OSX, introduced: 10.11) @available(iOS, introduced: 9.0)
  public static var coderValueNotFoundError: CocoaError.Code {
    return CocoaError.Code(rawValue: 4865)
  }
}

extension CocoaError {
  @available(OSX, introduced: 10.11) @available(iOS, introduced: 9.0)
  public var isCoderError: Bool {
    return code.rawValue >= 4864 && code.rawValue <= 4991
