UOM // Add capabilities of handling empty data files on load.
This commit is contained in:
parent
e01ddb47d8
commit
9766bea1a0
|
@ -194,6 +194,7 @@ extension vChewing.LMUserOverride {
|
||||||
let decoder = JSONDecoder()
|
let decoder = JSONDecoder()
|
||||||
do {
|
do {
|
||||||
let data = try Data(contentsOf: fileURL, options: .mappedIfSafe)
|
let data = try Data(contentsOf: fileURL, options: .mappedIfSafe)
|
||||||
|
if ["", "{}"].contains(String(data: data, encoding: .utf8)) { return }
|
||||||
guard let jsonResult = try? decoder.decode([String: KeyObservationPair].self, from: data) else {
|
guard let jsonResult = try? decoder.decode([String: KeyObservationPair].self, from: data) else {
|
||||||
IME.prtDebugIntel("UOM Error: Read file content type invalid, abort loading.")
|
IME.prtDebugIntel("UOM Error: Read file content type invalid, abort loading.")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue