Skip to content

Conversation

@jason-simmons
Copy link
Member

Fixes #7715

@jason-simmons
Copy link
Member Author

@Hixie

@Hixie
Copy link
Contributor

Hixie commented Apr 11, 2017

We should document in the dartdocs for load() and loadString() what the semantics are for the case where the asset is unavailable. Should they always throw? Always return null?

The fix in this PR only throws for the specific case of loadString() from an AssetBundle. It looks like the semantics for NetworkAssetBundle are to return null in the case of a successful load (!) for load(), and return null in the case of a failed load for loadString(); and for CachingAssetBundle, in case of failure load() returns null but loadString() throws. We should make this more consistent.

@jason-simmons
Copy link
Member Author

Changed all load() implementations to throw on a missing asset

Copy link
Contributor

Choose a reason for hiding this comment

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

please add this to loadString's dartdocs as well

Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably include information from response as well (like the status code, maybe more? I guess we don't want to include the whole body, that might be absurdly verbose).

See https://docs.flutter.io/flutter/foundation/FlutterError/message.html for some style notes about these error messages.

@Hixie
Copy link
Contributor

Hixie commented Apr 11, 2017

This is great.

Please add tests that verify the behaviour for the things for which you changed the behaviour.

LGTM.

@jason-simmons
Copy link
Member Author

Added a test for AssetBundle - PTAL

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: braces around multiline statements, and if you put a newline after the (, put a newline before the ).

Copy link
Contributor

Choose a reason for hiding this comment

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

isFlutterError

@Hixie
Copy link
Contributor

Hixie commented Apr 11, 2017

LGTM. Bonus points if you can also add a test for verifying the change to the network asset bundle... we really wouldn't want to regress the ==/!= 200 thing...

@jason-simmons jason-simmons merged commit c12c019 into flutter:master Apr 11, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CachingAssetBundle._fetchString gives poor error message

3 participants