Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10568] Errors thrown by JSONDecoder don't have meaningful messages shown to Xcode #3426

NSExceptional opened this issue Apr 27, 2019 · 2 comments


Copy link

@NSExceptional NSExceptional commented Apr 27, 2019

Previous ID SR-10568
Radar None
Original Reporter @NSExceptional
Type Improvement

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Foundation, Standard Library
Labels Improvement, Codable
Assignee None
Priority Medium

md5: 5be1df8769f1d742c91f8fdc5a7e5aec

Issue 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.

Copy link

@belkadan belkadan commented Apr 29, 2019

Can you attach a self-contained project or playground that demonstrates the issue? I'm not sure how to set up the test case such that you'd get this behavior.

Copy link

@NSExceptional NSExceptional commented Apr 29, 2019

Yes, I've attached a reduced test case. Trying to build it has made me realize it only seems to happen in a test environment when failed tests are reported; other environments like Playgrounds or regular debugging do show the appropriate error. My apologies. I've just seen this error before and it never occurred to me that I might have only seen it while testing.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants