Take no risks with unwrapped optionals

This commit is contained in:
Davide De Rosa 2019-04-28 21:50:18 +02:00
parent c6f154ec18
commit e6d67ac9f6
2 changed files with 4 additions and 2 deletions

View File

@ -111,7 +111,9 @@ public class InfrastructureFactory {
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)!)")
if let json = String(data: data, encoding: .utf8) {
log.warning(json)
}
continue
}

View File

@ -210,7 +210,7 @@ public struct InfrastructurePreset: Codable {
for entry in external {
rawExternal[entry.key.rawValue] = entry.value
}
try container.encodeIfPresent(rawExternal, forKey: .external)
try container.encode(rawExternal, forKey: .external)
}
var cfgContainer = container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration)