I am using JSONDecoder()
in Swift and need to get better error messages.
Within the debug description (for example) I can see messages like "The given data was not valid JSON", but I need to know it is that rather than a network error (for example).
let decoder = JSONDecoder()
if let data = data{
do {
// process data
} catch let error {
// can access error.localizedDescription but seemingly nothing else
}
I tried to cast to a DecodingError
, but this does not seem to reveal more information. I certainly don't need the string - even an error code is much more helpful than this...