Skip to content

Conversation

@albertusdev
Copy link
Contributor

@albertusdev albertusdev commented Oct 14, 2019

Description

This CL refactors more FlutterError messages to take advantage of structured error functionality and also increase the test coverage for all of the FlutterError that got refactored.
This is a follow up to #34684

Related Issues

Tests

  • Added lot more tests on the error message formatting

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@albertusdev albertusdev changed the title Structured errors WIP: Structured errors Oct 14, 2019
@fluttergithubbot fluttergithubbot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Oct 14, 2019
@albertusdev albertusdev force-pushed the structured-errors branch 5 times, most recently from c8b8556 to 87efe7c Compare October 16, 2019 17:06
@albertusdev albertusdev requested a review from jacob314 October 16, 2019 19:33
// LayoutDelegate that layout child with id 0 and 1
// Used in the 'performLayout error control test' test case for triggering
// For triggering an error when laying out non existent child
// For triggering an error when a child has not been laid out
Copy link
Contributor

Choose a reason for hiding this comment

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

"For triggering an error when a child has not been laid out" ==> "and a child that has not been laid out"

'All SemanticsHandle instances must be disposed by calling dispose() on '
'the SemanticsHandle.'
),
ErrorHint(
Copy link
Contributor

Choose a reason for hiding this comment

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

Fyi @InMatrix
added an extra line break here. This seems like a reasonable hint.

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

The tests for this code look really good overall!
Really an impressive job of testing a wide range of Widget and Render errors that had zero test coverage.
Lgtm from a Flutter DevExp perspective.
These error messages will really help us do a better job explaining to users what went wrong with their layouts.
lgtm
Adding @goderbauer for further review and fyi @InMatrix who will be excited to see this code land.
@goderbauer the good news is that about 2/3 of this code is tests so it isn't quite as painful to review as the line lengths suggest.

@jacob314 jacob314 requested a review from goderbauer October 18, 2019 05:06
Albertus Angga Raharja added 4 commits October 18, 2019 12:55
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

RSLGTM

I did not review every single line of this PR, but what I saw looked good.

@albertusdev albertusdev merged commit b31ca1a into flutter:master Oct 28, 2019
'${activeCurve.runtimeType} mapped $t to $transformedValue, which '
'is near $roundedTransformedValue.'
)
]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought FlutterError would automatically take its first line and use it as a summary and use the rest as a description, is that not the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I believe so too, this is actually redundant change
cc: @jacob314

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes go ahead and revert this change as part of your followup cleanup CL.

});

testWidgets('verifyTickersWereDisposed control test', (WidgetTester tester) async {
FlutterError error;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: indents are off here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes sorry for that :( should I make new PR to fix this?

Copy link
Contributor

Choose a reason for hiding this comment

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

no worries. go ahead and create a new PR with just the whitespace fix. Good news is whitespace only CLs are really quick to review. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

roger that! :)

'existing handle will leak into another test and alter its behavior.'
);
// TODO(jacobr): The hint for this one causes a change in line breaks but
// I think it is for the best.
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure what this TODO means?

Copy link
Contributor Author

@albertusdev albertusdev Oct 28, 2019

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this todo.

'$runtimeType does not have a child widget but received a non-empty list of child SemanticsNode:\n'
'${children.join('\n')}'
);
throw FlutterError.fromParts(<DiagnosticsNode>[
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we missed this one, this one is changing everything to be summary, is this intended?
@jacob314

Copy link
Contributor

Choose a reason for hiding this comment

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

good catch. Only the first line should be the summary.

Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Nov 26, 2019
…#42640)

* Add structured errors in Animations, TabView, ChangeNotifier

* Add structured error on MaterialPageRoute, BoxBorder, DecorationImagePainter, TextSpan

* Add structured errors in Debug

* Fix test errors

* Add structured errors in Scaffold and Stepper

* Add structured errors in part of Rendering Layer

* Fix failing test due to FloatingPoint precision

* Fix failing tests due to precision error and not using final

* Fix failing test due to floating precision error with RegEx instead

* Add structured error in CustomLayout and increase test coverage

* Add structured error & its test in ListBody

* Add structured error in ProxyBox and increase test coverage

* Add structured error message in Viewport

* Fix styles and add more assertions on ErrorHint and DiagnosticProperty

* Add structured error in scheduler/binding and scheduler/ticker

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Add structured error in AssetBundle and TextInput

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Add structured errors in several widgets #1

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Remove unused import

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Add assertions on hint messages

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Fix catch spacing

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Add structured error in several widgets part 2 and increase code coverage

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Add structured error in flutter_test/widget_tester

* Fix floating precision accuracy by using RegExp

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Remove todo to add tests in Scaffold showBottomSheet

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Fix reviews by indenting lines and fixing the assertion orders

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Fix failing tests due to renaming class

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Try skipping the NetworkBundleTest

Signed-off-by: Albertus Angga Raharja <[email protected]>

* Remove leading space in material/debug error hint

Signed-off-by: Albertus Angga Raharja <[email protected]>
gspencergoog pushed a commit that referenced this pull request Feb 20, 2020
This PR is a follow up of #42640
Some changes of that PR includes redundant changes using FlutterError.fromParts constructor even though it's not necessary.

Some minor changes are:

- Remove one unnecessary todo
- Fix indent consistencies
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants