Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ extension DiskPersistence {

cachedStoreInfo = storeInfo
return storeInfo
} catch URLError.fileDoesNotExist, CocoaError.fileNoSuchFile, CocoaError.fileReadNoSuchFile, POSIXError.ENOENT {
} catch FileNotFoundError() {
return nil
} catch {
throw error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// FileNotFoundError.swift
// https://github.com/mochidev/CodableDatastore
//
// Created by Dimitri Bouniol on 2026-08-30.
// Copyright © 2023-26 Mochi Development, Inc. All rights reserved.
// mochidev-codable-datastore: 8A3D87799CB24B2BA7A7661369B88325
//

import Foundation

struct FileNotFoundError: Error {
static func ~= (lhs: FileNotFoundError, rhs: any Error) -> Bool {
(rhs as any FileError).isFileNotFound == true
}
}

protocol FileError {
var isFileNotFound: Bool { get }
}

extension NSError: FileError {
var isFileNotFound: Bool {
URLError.fileDoesNotExist ~= self || CocoaError.fileReadNoSuchFile ~= self || CocoaError.fileNoSuchFile ~= self || POSIXError.ENOENT ~= self
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extension Snapshot {

cachedManifest = manifest
return manifest
} catch URLError.fileDoesNotExist, CocoaError.fileNoSuchFile, CocoaError.fileReadNoSuchFile, POSIXError.ENOENT {
} catch FileNotFoundError() {
return SnapshotManifest(id: id, modificationDate: Date())
} catch {
throw error
Expand Down