-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Improve exceptions thrown by asset bundle #114139
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
Improve exceptions thrown by asset bundle #114139
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
We should add a test for this, just for completeness. Maybe while we're at it we could add more detail? Not sure if there's any more detail to add though. |
|
Wow I can't even find proper tests with |
| /// isolate to avoid jank on the main thread. | ||
| Future<String> loadString(String key, { bool cache = true }) async { | ||
| final ByteData data = await load(key); | ||
| if (data == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed. But the analyzer doesn't report with an unnecessary null check.
. when throwing exceptions in asset bundle|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| }, skip: isBrowser); // https://github.com/flutter/flutter/issues/39998 | ||
|
|
||
| test('Throws expected exceptions when loading not exists asset', () async { | ||
| TestWidgetsFlutterBinding.ensureInitialized(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One strange thing I found during tests is if we call the ensureInitialized in this test file, the "NetworkAssetBundle control test" will fail because the request returns 400 instead of 404.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the widget tester overrides HTTP calls to always return 400.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the widget tester overrides HTTP calls to always return 400.
TIL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually I update the test to use 400 instead.
| /// isolate to avoid jank on the main thread. | ||
| Future<String> loadString(String key, { bool cache = true }) async { | ||
| final ByteData data = await load(key); | ||
| if (data == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to keep this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You see, the data here is not nullable, so it should be a unnecessary check IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I'm also wondering why the analyzer doesn't report about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh interesting, ok. Maybe because of unsound null safety?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take another look to see if there are any issues with the linter rule.
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Consist messages when throwing from asset bundles.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.