From 34495d7163c9cdc7d326701a72fd0c5bda1c5728 Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Mon, 7 Mar 2016 07:35:55 +0900 Subject: [PATCH] WIP: prevent error when adding non-existent file --- CoreStore/Migrating/DataStack+Migration.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CoreStore/Migrating/DataStack+Migration.swift b/CoreStore/Migrating/DataStack+Migration.swift index bea80b9..36a98f1 100644 --- a/CoreStore/Migrating/DataStack+Migration.swift +++ b/CoreStore/Migrating/DataStack+Migration.swift @@ -282,9 +282,12 @@ public extension DataStack { options: storage.storeOptions ) } + catch let error as NSError where error.code == NSFileReadNoSuchFileError && error.domain == NSCocoaErrorDomain { + + return [] + } catch { - // TODO: throws when file not exists yet CoreStore.handleError( error as NSError, "Failed to load \(typeName(storage)) metadata from URL \"\(fileURL)\"."