What are all the errors that can be thrown by FileManager
's methods? Specifically, I'm interested in the errors throwable by attributesOfItem(atPath:)
.
This is how I want to use it:
do {
let inode = try FileManager.default.attributesOfItem(atPath: somePath)[.systemFileNumber]
} catch SomeError.someSpecificError (let someContext) {
/* implementation omitted... */
}
It can be like the following (see more file related constants in documentation for CocoaError
)
do {
let inode = try FileManager.default.attributesOfItem(atPath: somePath)[.systemFileNumber]
} catch CocoaError.fileNoSuchFile {
print("Error: no such file exists")
} catch CocoaError.fileReadNoPermission {
print("Error: you don't have permissions")
} catch {
// something unknown
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With