From b714f8acd9deefa406672a2046f18d8a41bba5dc Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 28 Apr 2019 21:33:08 +0200 Subject: [PATCH] Log cached infra JSON when unable to parse --- Passepartout/Sources/Services/InfrastructureFactory.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Passepartout/Sources/Services/InfrastructureFactory.swift b/Passepartout/Sources/Services/InfrastructureFactory.swift index 54aee817..197ba146 100644 --- a/Passepartout/Sources/Services/InfrastructureFactory.swift +++ b/Passepartout/Sources/Services/InfrastructureFactory.swift @@ -106,7 +106,12 @@ public class InfrastructureFactory { guard let data = try? Data(contentsOf: entry) else { continue } - guard let infra = try? decoder.decode(Infrastructure.self, from: data) else { + let infra: Infrastructure + do { + infra = try decoder.decode(Infrastructure.self, from: data) + } catch let e { + log.warning("Unable to load infrastructure \(entry.lastPathComponent): \(e)") + log.warning("\(String(data: data, encoding: .utf8)!)") continue }