Parse-Swift
Parse-Swift copied to clipboard
More helpful error logging on Invalid data format
New Pull Request Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am creating this PR in reference to an issue.
Issue Description
Decoding errors from "error decoding parse server response" can be quite tricky as the error log doesn't provide anything helpful.
Let's say you have a struct with the key firstName as Int, and Parse Server sends a firstName as string.
The error you will get is:
The data couldn’t be read because it isn’t in the correct format, which isn't very helpful.
Related issue: n/a
Approach
This PR changes the error to print:
typeMismatch(Swift.Int, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "firstName", intValue: nil)], debugDescription: "Expected to decode Int but found a string/data instead.", underlyingError: nil))
TODOs before merging
- [ ] Add tests
- [ ] Add entry to changelog
- [ ] Add changes to documentation (guides, repository pages, in-code descriptions)
Thanks for opening this pull request!
- 🎉 We are excited about your hands-on contribution!
Codecov Report
Merging #388 (60728ba) into main (0c5d7f6) will increase coverage by
0.02%. The diff coverage is33.33%.
@@ Coverage Diff @@
## main #388 +/- ##
==========================================
+ Coverage 89.14% 89.16% +0.02%
==========================================
Files 156 156
Lines 14528 14528
==========================================
+ Hits 12951 12954 +3
+ Misses 1577 1574 -3
| Impacted Files | Coverage Δ | |
|---|---|---|
| Sources/ParseSwift/Extensions/URLSession.swift | 77.16% <33.33%> (ø) |
|
| Sources/ParseSwift/Objects/ParseUser.swift | 86.12% <0.00%> (-0.09%) |
:arrow_down: |
| Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift | 76.75% <0.00%> (+0.58%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Is this ready for review?
Yep!