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

feat: improve logging of decoding errors #388

Merged
merged 4 commits into from Aug 17, 2022

Conversation

dblythy
Copy link
Member

@dblythy dblythy commented Aug 11, 2022

New Pull Request Checklist

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)

@parse-github-assistant
Copy link

parse-github-assistant bot commented Aug 11, 2022

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@codecov
Copy link

codecov bot commented Aug 11, 2022

Codecov Report

Merging #388 (60728ba) into main (0c5d7f6) will increase coverage by 0.02%.
The diff coverage is 33.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%) ⬇️
Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift 76.75% <0.00%> (+0.58%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@cbaker6 cbaker6 changed the title More helpful error logging on Invalid data format feat: improve logging of decoding errors Aug 15, 2022
@cbaker6
Copy link
Contributor

cbaker6 commented Aug 15, 2022

Is this ready for review?

@dblythy
Copy link
Member Author

dblythy commented Aug 15, 2022

Yep!

Copy link
Contributor

@cbaker6 cbaker6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cbaker6 cbaker6 merged commit 50f655b into parse-community:main Aug 17, 2022
@dblythy dblythy deleted the optimize-errors branch August 26, 2022 00:46
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.

None yet

2 participants