Created
October 20, 2021 08:25
-
-
Save hsleedevelop/1ec71cd52310df639304e17578bedad6 to your computer and use it in GitHub Desktop.
Codable debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do { | |
let output = try decoder.decode(FlanetNotification.self, from: data) | |
App.ui.alert(message:"parsed!!!", callback: nil) | |
} catch DecodingError.dataCorrupted(let context) { | |
App.ui.alert(message: context.debugDescription, callback: nil) | |
} catch DecodingError.keyNotFound(let key, let context) { | |
App.ui.alert(title: "Key '\(key)' not found:", message: context.debugDescription, callback: nil) | |
App.ui.alert(title: "codingPath: \(context.codingPath)", message: context.debugDescription, callback: nil) | |
} catch DecodingError.valueNotFound(let value, let context) { | |
print("Value '\(value)' not found:", context.debugDescription) | |
print("codingPath:", context.codingPath) | |
App.ui.alert(title: "Value '\(value)' not found:", message: context.debugDescription, callback: nil) | |
App.ui.alert(title: "codingPath: \(context.codingPath)", message: context.debugDescription, callback: nil) | |
} catch DecodingError.typeMismatch(let type, let context) { | |
print("Type '\(type)' mismatch:", context.debugDescription) | |
print("codingPath:", context.codingPath) | |
App.ui.alert(title: "Type '\(type)' mismatch:", message: context.debugDescription, callback: nil) | |
App.ui.alert(title: "codingPath: \(context.codingPath)", message: context.debugDescription, callback: nil) | |
} catch { | |
print("error: ", error) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment