Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
5b1aa60a
Unverified
Commit
5b1aa60a
authored
Dec 29, 2020
by
Kenzie Schmoll
Committed by
GitHub
Dec 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable structured errors by default. (#72446)
* Enable structured errors by default.
parent
fa86fb75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+9
-1
widget_inspector_structure_error_test.dart
...r/test/widgets/widget_inspector_structure_error_test.dart
+10
-5
No files found.
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
5b1aa60a
...
...
@@ -960,7 +960,15 @@ mixin WidgetInspectorService {
/// Structured errors provide semantic information that can be used by IDEs
/// to enhance the display of errors with rich formatting.
bool
isStructuredErrorsEnabled
()
{
return
const
bool
.
fromEnvironment
(
'flutter.inspector.structuredErrors'
);
// This is a debug mode only feature and will default to false for
// profile mode.
bool
enabled
=
false
;
assert
(()
{
// TODO(kenz): add support for structured errors on the web.
enabled
=
const
bool
.
fromEnvironment
(
'flutter.inspector.structuredErrors'
,
defaultValue:
!
kIsWeb
);
return
true
;
}());
return
enabled
;
}
/// Called to register service extensions.
...
...
packages/flutter/test/widgets/widget_inspector_structure_error_test.dart
View file @
5b1aa60a
...
...
@@ -56,14 +56,14 @@ class StructureErrorTestWidgetInspectorService extends Object with WidgetInspect
final
StructureErrorTestWidgetInspectorService
service
=
StructureErrorTestWidgetInspectorService
();
WidgetInspectorService
.
instance
=
service
;
test
(
'ext.flutter.inspector.structuredErrors
still report error to original
on error'
,
()
async
{
test
(
'ext.flutter.inspector.structuredErrors
reports error to _structuredExceptionHandler
on error'
,
()
async
{
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
late
FlutterErrorDetails
actualError
;
bool
usingNewHandler
=
false
;
// Creates a spy onError. This spy needs to be set before widgets binding
// initializes.
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
actualError
=
details
;
usingNewHandler
=
true
;
};
WidgetsFlutterBinding
.
ensureInitialized
();
...
...
@@ -81,8 +81,13 @@ class StructureErrorTestWidgetInspectorService extends Object with WidgetInspect
);
FlutterError
.
reportError
(
expectedError
);
// Validates the spy still received an error.
expect
(
actualError
,
expectedError
);
// For non-web apps, this validates the new handler did not receive an
// error because `FlutterError.onError` was set to
// `WidgetInspectorService._structuredExceptionHandler` when service
// extensions were initialized. For web apps, the new handler should
// have received an error because structured errors are disabled by
// default on the web.
expect
(
usingNewHandler
,
equals
(
kIsWeb
));
}
finally
{
FlutterError
.
onError
=
oldHandler
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment