Skip to content

Codable: improved decoding errors#3153

Merged
NachoSoto merged 1 commit into
mainfrom
codable-error-type
Sep 7, 2023
Merged

Codable: improved decoding errors#3153
NachoSoto merged 1 commit into
mainfrom
codable-error-type

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Sep 6, 2023

Copy link
Copy Markdown
Contributor

This adds the type to the errors.

Before:

2023-09-06 15:58:05.394583-0700 xctest[55784:3435527] [codable] DEBUG: ℹ️ Encountered error when decoding JSON: not an event

After:

2023-09-06 16:03:29.606223-0700 xctest[57222:3447821] [codable] DEBUG: ℹ️ Encountered error when decoding JSON for 'PaywallStoredEvent': this is not an event

This adds the type to the errors.

```
2023-09-06 15:58:05.394583-0700 xctest[55784:3435527] [codable] DEBUG: ℹ️ Encountered error when decoding JSON: not an event
2023-09-06 15:58:05.407965-0700 xctest[55784:3435527] [codable] ERROR: 😿‼️ Couldn't decode data from json, it was corrupted: Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Something looked like a 'null' but wasn't around line 1, column 0." UserInfo={NSDebugDescription=Something looked like a 'null' but wasn't around line 1, column 0., NSJSONSerializationErrorIndex=0}))
```

```
2023-09-06 16:03:29.606223-0700 xctest[57222:3447821] [codable] DEBUG: ℹ️ Encountered error when decoding JSON for 'PaywallStoredEvent': this is not an event
2023-09-06 16:03:29.606329-0700 xctest[57222:3447821] [codable] ERROR: 😿‼️ Couldn't decode data from json, it was corrupted: Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Something looked like a 'true' but wasn't around line 1, column 0." UserInfo={NSDebugDescription=Something looked like a 'true' but wasn't around line 1, column 0., NSJSONSerializationErrorIndex=0}))
```
@NachoSoto NachoSoto requested a review from a team September 6, 2023 23:14
@codecov

codecov Bot commented Sep 7, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (8243593) 86.60% compared to head (016e6b0) 86.61%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3153      +/-   ##
==========================================
+ Coverage   86.60%   86.61%   +0.01%     
==========================================
  Files         219      219              
  Lines       15715    15715              
==========================================
+ Hits        13610    13612       +2     
+ Misses       2105     2103       -2     
Files Changed Coverage Δ
...rces/FoundationExtensions/Decoder+Extensions.swift 72.27% <100.00%> (ø)
Sources/Logging/Strings/CodableStrings.swift 94.44% <100.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@NachoSoto NachoSoto merged commit 5527f88 into main Sep 7, 2023
@NachoSoto NachoSoto deleted the codable-error-type branch September 7, 2023 14:19
NachoSoto pushed a commit that referenced this pull request Sep 14, 2023
**This is an automatic release.**

### Bugfixes
* Fix runtime crash in SK2TransactionListener in iOS < 15 (#3206) via
Toni Rico (@tonidero)
### Performance Improvements
* `OperationDispatcher`: add support for "long" delays (#3168) via
NachoSoto (@NachoSoto)
### Other Changes
* `Integration Tests`: add tests for ghost transfer behavior (#3135) via
NachoSoto (@NachoSoto)
* `Xcode`: removed `purchases-ios` SPM reference (#3166) via NachoSoto
(@NachoSoto)
* `Integration Tests`: another flaky failure (#3165) via NachoSoto
(@NachoSoto)
* `Integration Tests`: fix flaky test failure due to leftover
transaction (#3167) via NachoSoto (@NachoSoto)
* `Xcode 13`: removed last `Swift 5.7` checks (#3161) via NachoSoto
(@NachoSoto)
* `Integration Tests`: improve flaky tests (#3163) via NachoSoto
(@NachoSoto)
* `Codable`: improved decoding errors (#3153) via NachoSoto (@NachoSoto)
* Refactor: extract `HealthOperation` (#3154) via NachoSoto (@NachoSoto)
* `Xcode 13`: remove conditional code (#3147) via NachoSoto (@NachoSoto)
* `CircleCI`: change all jobs to use `Xcode 14.x` and replace
`xcode-install` with `xcodes` (#2421) via NachoSoto (@NachoSoto)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants