CocoaError
Describes errors within the Cocoa error domain, including errors that Foundation throws.
- iOS
- 8.0+
- macOS
- 10.10+
- tvOS
- 9.0+
- watchOS
- 2.0+
struct CocoaError
Describes errors within the Cocoa error domain, including errors that Foundation throws.
struct CocoaError
import FoundationEssentials
protocol Error : Sendable
A type representing an error value that can be thrown.
protocol Sendable
init(_ code: CocoaError.Code, userInfo: [String : Any] = [:])
static var errorDomain: String { get }
static var executableArchitectureMismatch: CocoaError.Code { get }
static var executableLink: CocoaError.Code { get }
static var executableLoad: CocoaError.Code { get }
static var executableNotLoadable: CocoaError.Code { get }
static var executableRuntimeMismatch: CocoaError.Code { get }
static var featureUnsupported: CocoaError.Code { get }
static var fileLocking: CocoaError.Code { get }
static var fileManagerUnmountBusy: CocoaError.Code { get }
static var fileManagerUnmountUnknown: CocoaError.Code { get }
static var fileNoSuchFile: CocoaError.Code { get }
static var fileReadCorruptFile: CocoaError.Code { get }
static var fileReadInapplicableStringEncoding: CocoaError.Code { get }
static var fileReadInvalidFileName: CocoaError.Code { get }
static var fileReadNoPermission: CocoaError.Code { get }
static var fileReadNoSuchFile: CocoaError.Code { get }
static var fileReadTooLarge: CocoaError.Code { get }
static var fileReadUnknown: CocoaError.Code { get }
static var fileReadUnknownStringEncoding: CocoaError.Code { get }
static var fileReadUnsupportedScheme: CocoaError.Code { get }
static var fileWriteFileExists: CocoaError.Code { get }
static var fileWriteInapplicableStringEncoding: CocoaError.Code { get }
static var fileWriteInvalidFileName: CocoaError.Code { get }
static var fileWriteNoPermission: CocoaError.Code { get }
static var fileWriteOutOfSpace: CocoaError.Code { get }
static var fileWriteUnknown: CocoaError.Code { get }
static var fileWriteUnsupportedScheme: CocoaError.Code { get }
static var fileWriteVolumeReadOnly: CocoaError.Code { get }
static var formatting: CocoaError.Code { get }
static var keyValueValidation: CocoaError.Code { get }
static var propertyListReadCorrupt: CocoaError.Code { get }
static var propertyListReadStream: CocoaError.Code { get }
static var propertyListReadUnknownVersion: CocoaError.Code { get }
static var propertyListWriteInvalid: CocoaError.Code { get }
static var propertyListWriteStream: CocoaError.Code { get }
static var userCancelled: CocoaError.Code { get }
static func error(_ code: CocoaError.Code, userInfo: [String : AnyHashable]? = nil, url: URL? = nil) -> any Error
let code: CocoaError.Code
var filePath: String? { get }
The file path associated with the error, if any.
var isCoderError: Bool { get }
var isExecutableError: Bool { get }
var isFileError: Bool { get }
var isFormattingError: Bool { get }
var isPropertyListError: Bool { get }
var isValidationError: Bool { get }
var stringEncoding: String.Encoding? { get }
The string encoding associated with this error, if any.
var underlying: (any Error)? { get }
The underlying error behind this error, if any.
var underlyingErrors: [any Error] { get }
A list of underlying errors, if any. It includes the values of both NSUnderlyingErrorKey and NSMultipleUnderlyingErrorsKey. If there are no underlying errors, returns an empty array.
var url: URL? { get }
The URL associated with this error, if any.
nonisolated(unsafe) let userInfo: [String : Any]
struct Code
The error code itself.
import Foundation
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol CustomNSError : Error
Describes an error type that specifically provides a domain, code, and user-info dictionary.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
static var coderInvalidValue: CocoaError.Code { get }
static var coderReadCorrupt: CocoaError.Code { get }
static var coderValueNotFound: CocoaError.Code { get }
static var ubiquitousFileNotUploadedDueToQuota: CocoaError.Code { get }
static var ubiquitousFileUbiquityServerNotAvailable: CocoaError.Code { get }
static var ubiquitousFileUnavailable: CocoaError.Code { get }
static var userActivityConnectionUnavailable: CocoaError.Code { get }
static var userActivityHandoffFailed: CocoaError.Code { get }
static var userActivityHandoffUserInfoTooLarge: CocoaError.Code { get }
static var userActivityRemoteApplicationTimedOut: CocoaError.Code { get }
static var xpcConnectionInterrupted: CocoaError.Code { get }
static var xpcConnectionInvalid: CocoaError.Code { get }
static var xpcConnectionReplyInvalid: CocoaError.Code { get }
var isUbiquitousFileError: Bool { get }
var isUserActivityError: Bool { get }
var isXPCConnectionError: Bool { get }
static var errorDomain: String { get }
Default domain of the error.
var localizedDescription: String { get }
Retrieve the localized description for this error.
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.