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

fix: Handle parsing errors #40

Merged
merged 5 commits into from
Apr 18, 2024

Conversation

andreas-unleash
Copy link
Contributor

@andreas-unleash andreas-unleash commented Apr 15, 2024

Catch any errors from parsing toggles from storage
Relates to #39

var decoded = jsonDecode(body);

// Return an empty map if 'toggles' isn't a list or doesn't exist
if (decoded['toggles'] is! List) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd really rather avoid checking for a list here. Stuff should fail and the new catch block should catch that, right? I don't really see a reason this function needs to change, it looks like it's correct, it's getting fed garbage data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure makes sense - this was my initial fix, but the try/catch should be enough here agreed

Copy link
Member

Choose a reason for hiding this comment

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

Nice! I think this looks good, but maybe we keep this open until we understand more about this problem. I'd need to go root around a little in the code

@andreas-unleash andreas-unleash changed the title fix: Handle parsing errors elegantly, skipping incorrectly formatted entries fix: Handle parsing errors Apr 17, 2024
Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

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

Yeah let's do the thing

@andreas-unleash andreas-unleash merged commit e8a5274 into main Apr 18, 2024
2 checks passed
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