Uploaded image for project: 'Swift'
  1. Swift
  2. SR-10568

Errors thrown by JSONDecoder don't have meaningful messages shown to Xcode

    XMLWordPrintable

    Details

      Description

      What Xcode shows you:

      The data couldn’t be read because it is missing.
      

      What the actual underlying error, which is actually useful:

      No value associated with key CodingKeys(stringValue: \"age\", intValue: nil) (\"age\").
      

      To see this error in detail, you have to jump through some hoops and print it in the debugger, when the Xcode test suite should just show you the more descriptive error in the first place:

      do {
          let t: T = decoder.decode(T.self, ...)
      } catch {
          let _ = error // breakpoint here, po error
      }
      

      I assume this is as simple as making the `.failureReason` more descriptive. I couldn't find where `DecodingError` was defined in `apple/swift-corelibs-foundation` or I would have checked.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tannerbennett Tanner Bennett
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: