From e91b5a00b4c29e408bae5e49c82a6636ce96d7db Mon Sep 17 00:00:00 2001 From: Ali Moazenzadeh Date: Sat, 25 Sep 2021 09:01:45 +0330 Subject: [PATCH] Fix null probability --- Sources/NetShears/NetShears.swift | 2 +- Sources/NetShears/Protocols/PersistHelper.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/NetShears/NetShears.swift b/Sources/NetShears/NetShears.swift index 9de4e93..daa7405 100644 --- a/Sources/NetShears/NetShears.swift +++ b/Sources/NetShears/NetShears.swift @@ -13,7 +13,7 @@ public final class NetShears: NSObject { let networkRequestInterceptor = NetworkRequestInterceptor() lazy var config: NetworkInterceptorConfig = { var savedModifiers = [RequestEvaluatorModifier]().retrieveFromDisk() - return NetworkInterceptorConfig(modifiers: savedModifiers) + return NetworkInterceptorConfig(modifiers: savedModifiers ?? []) }() diff --git a/Sources/NetShears/Protocols/PersistHelper.swift b/Sources/NetShears/Protocols/PersistHelper.swift index 4a2263a..1485d24 100644 --- a/Sources/NetShears/Protocols/PersistHelper.swift +++ b/Sources/NetShears/Protocols/PersistHelper.swift @@ -51,11 +51,11 @@ public class PersistHelper { /// - directory: directory where struct data is stored /// - type: struct type (i.e. Message.self) /// - Returns: decoded struct model(s) of data - static func retrieve(_ fileName: String, as type: T.Type) -> T { + static func retrieve(_ fileName: String, as type: T.Type) -> T? { let url = getURL().appendingPathComponent(fileName, isDirectory: false) if !FileManager.default.fileExists(atPath: url.path) { - fatalError("File at path \(url.path) does not exist!") + return nil } if let data = FileManager.default.contents(atPath: url.path) {