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
d482163f
Unverified
Commit
d482163f
authored
Apr 23, 2020
by
chunhtai
Committed by
GitHub
Apr 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix FlutterError.onError in debug mode (#53843)" (#55484)
This reverts commit
d35671c6
.
parent
07a804cc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
11 additions
and
115 deletions
+11
-115
assertions.dart
packages/flutter/lib/src/foundation/assertions.dart
+2
-13
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+3
-3
scaffold_test.dart
packages/flutter/test/material/scaffold_test.dart
+1
-1
image_test.dart
packages/flutter/test/widgets/image_test.dart
+0
-2
widget_inspector_structure_error_test.dart
...r/test/widgets/widget_inspector_structure_error_test.dart
+0
-91
widget_inspector_test.dart
packages/flutter/test/widgets/widget_inspector_test.dart
+2
-2
binding.dart
packages/flutter_test/lib/src/binding.dart
+3
-3
No files found.
packages/flutter/lib/src/foundation/assertions.dart
View file @
d482163f
...
...
@@ -715,7 +715,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
/// Called whenever the Flutter framework catches an error.
///
/// The default behavior is to call [
presentError
].
/// The default behavior is to call [
dumpErrorToConsole
].
///
/// You can set this to your own function to override this default behavior.
/// For example, you could report all errors to your server.
...
...
@@ -725,18 +725,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
///
/// Set this to null to silently catch and ignore errors. This is not
/// recommended.
static
FlutterExceptionHandler
onError
=
(
FlutterErrorDetails
details
)
=>
presentError
(
details
);
/// Called whenever the Flutter framework wants to present an error to the
/// users.
///
/// The default behavior is to call [dumpErrorToConsole].
///
/// Plugins can override how an error is to be presented to the user. For
/// example, the structured errors service extension sets its own method when
/// the extension is enabled. If you want to change how Flutter responds to an
/// error, use [onError] instead.
static
FlutterExceptionHandler
presentError
=
dumpErrorToConsole
;
static
FlutterExceptionHandler
onError
=
dumpErrorToConsole
;
static
int
_errorCount
=
0
;
...
...
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
d482163f
...
...
@@ -959,13 +959,13 @@ mixin WidgetInspectorService {
SchedulerBinding
.
instance
.
addPersistentFrameCallback
(
_onFrameStart
);
final
FlutterExceptionHandler
structuredExceptionHandler
=
_reportError
;
final
FlutterExceptionHandler
defaultExceptionHandler
=
FlutterError
.
present
Error
;
final
FlutterExceptionHandler
defaultExceptionHandler
=
FlutterError
.
on
Error
;
_registerBoolServiceExtension
(
name:
'structuredErrors'
,
getter:
()
async
=>
FlutterError
.
present
Error
==
structuredExceptionHandler
,
getter:
()
async
=>
FlutterError
.
on
Error
==
structuredExceptionHandler
,
setter:
(
bool
value
)
{
FlutterError
.
present
Error
=
value
?
structuredExceptionHandler
:
defaultExceptionHandler
;
FlutterError
.
on
Error
=
value
?
structuredExceptionHandler
:
defaultExceptionHandler
;
return
Future
<
void
>.
value
();
},
);
...
...
packages/flutter/test/material/scaffold_test.dart
View file @
d482163f
...
...
@@ -1840,7 +1840,7 @@ void main() {
final
GlobalKey
<
ScaffoldState
>
key
=
GlobalKey
<
ScaffoldState
>();
const
Key
buttonKey
=
Key
(
'button'
);
final
List
<
FlutterErrorDetails
>
errors
=
<
FlutterErrorDetails
>[];
FlutterError
.
present
Error
=
(
FlutterErrorDetails
error
)
=>
errors
.
add
(
error
);
FlutterError
.
on
Error
=
(
FlutterErrorDetails
error
)
=>
errors
.
add
(
error
);
int
state
=
0
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
packages/flutter/test/widgets/image_test.dart
View file @
d482163f
...
...
@@ -528,7 +528,6 @@ void main() {
final
ImageListener
listener
=
(
ImageInfo
info
,
bool
synchronous
)
{
capturedImage
=
info
;
};
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
FlutterError
.
onError
=
(
FlutterErrorDetails
flutterError
)
{
reportedException
=
flutterError
.
exception
;
reportedStackTrace
=
flutterError
.
stack
;
...
...
@@ -565,7 +564,6 @@ void main() {
// The image stream error handler should have the original exception.
expect
(
capturedException
,
testException
);
expect
(
capturedStackTrace
,
testStack
);
FlutterError
.
onError
=
oldHandler
;
});
testWidgets
(
'Duplicate listener registration does not affect error listeners'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/widgets/widget_inspector_structure_error_test.dart
deleted
100644 → 0
View file @
07a804cc
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
StructureErrorTestWidgetInspectorService
.
runTests
();
}
typedef
InspectorServiceExtensionCallback
=
FutureOr
<
Map
<
String
,
Object
>>
Function
(
Map
<
String
,
String
>
parameters
);
class
StructureErrorTestWidgetInspectorService
extends
Object
with
WidgetInspectorService
{
final
Map
<
String
,
InspectorServiceExtensionCallback
>
extensions
=
<
String
,
InspectorServiceExtensionCallback
>{};
final
Map
<
String
,
List
<
Map
<
Object
,
Object
>>>
eventsDispatched
=
<
String
,
List
<
Map
<
Object
,
Object
>>>{};
@override
void
registerServiceExtension
({
@required
String
name
,
@required
FutureOr
<
Map
<
String
,
Object
>>
callback
(
Map
<
String
,
String
>
parameters
),
})
{
assert
(!
extensions
.
containsKey
(
name
));
extensions
[
name
]
=
callback
;
}
@override
void
postEvent
(
String
eventKind
,
Map
<
Object
,
Object
>
eventData
)
{
getEventsDispatched
(
eventKind
).
add
(
eventData
);
}
List
<
Map
<
Object
,
Object
>>
getEventsDispatched
(
String
eventKind
)
{
return
eventsDispatched
.
putIfAbsent
(
eventKind
,
()
=>
<
Map
<
Object
,
Object
>>[]);
}
Iterable
<
Map
<
Object
,
Object
>>
getServiceExtensionStateChangedEvents
(
String
extensionName
)
{
return
getEventsDispatched
(
'Flutter.ServiceExtensionStateChanged'
)
.
where
((
Map
<
Object
,
Object
>
event
)
=>
event
[
'extension'
]
==
extensionName
);
}
Future
<
String
>
testBoolExtension
(
String
name
,
Map
<
String
,
String
>
arguments
)
async
{
expect
(
extensions
,
contains
(
name
));
// Encode and decode to JSON to match behavior using a real service
// extension where only JSON is allowed.
return
json
.
decode
(
json
.
encode
(
await
extensions
[
name
](
arguments
)))[
'enabled'
]
as
String
;
}
static
void
runTests
()
{
final
StructureErrorTestWidgetInspectorService
service
=
StructureErrorTestWidgetInspectorService
();
WidgetInspectorService
.
instance
=
service
;
test
(
'ext.flutter.inspector.structuredErrors still report error to original on error'
,
()
async
{
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
FlutterErrorDetails
actualError
;
// Creates a spy onError. This spy needs to be set before widgets binding
// initializes.
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
actualError
=
details
;
};
WidgetsFlutterBinding
.
ensureInitialized
();
try
{
// Enables structured errors.
expect
(
await
service
.
testBoolExtension
(
'structuredErrors'
,
<
String
,
String
>{
'enabled'
:
'true'
}),
equals
(
'true'
));
// Creates an error.
final
FlutterErrorDetails
expectedError
=
FlutterErrorDetailsForRendering
(
library
:
'rendering library'
,
context:
ErrorDescription
(
'during layout'
),
exception:
StackTrace
.
current
,
);
FlutterError
.
reportError
(
expectedError
);
// Validates the spy still received an error.
expect
(
actualError
,
expectedError
);
}
finally
{
FlutterError
.
onError
=
oldHandler
;
}
});
}
}
\ No newline at end of file
packages/flutter/test/widgets/widget_inspector_test.dart
View file @
d482163f
...
...
@@ -2280,7 +2280,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
List
<
Map
<
Object
,
Object
>>
flutterErrorEvents
=
service
.
getEventsDispatched
(
'Flutter.Error'
);
expect
(
flutterErrorEvents
,
isEmpty
);
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
present
Error
;
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
on
Error
;
try
{
// Enable structured errors.
...
...
@@ -2337,7 +2337,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
error
=
flutterErrorEvents
.
last
;
expect
(
error
[
'errorsSinceReload'
],
0
);
}
finally
{
FlutterError
.
present
Error
=
oldHandler
;
FlutterError
.
on
Error
=
oldHandler
;
}
});
...
...
packages/flutter_test/lib/src/binding.dart
View file @
d482163f
...
...
@@ -572,9 +572,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
})
{
assert
(
description
!=
null
);
assert
(
inTest
);
_oldExceptionHandler
=
FlutterError
.
present
Error
;
_oldExceptionHandler
=
FlutterError
.
on
Error
;
int
_exceptionCount
=
0
;
// number of un-taken exceptions
FlutterError
.
present
Error
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
on
Error
=
(
FlutterErrorDetails
details
)
{
if
(
_pendingExceptionDetails
!=
null
)
{
debugPrint
=
debugPrintOverride
;
// just in case the test overrides it -- otherwise we won't see the errors!
if
(
_exceptionCount
==
0
)
{
...
...
@@ -800,7 +800,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// Called by the [testWidgets] function after a test is executed.
void
postTest
()
{
assert
(
inTest
);
FlutterError
.
present
Error
=
_oldExceptionHandler
;
FlutterError
.
on
Error
=
_oldExceptionHandler
;
_pendingExceptionDetails
=
null
;
_parentZone
=
null
;
buildOwner
.
focusManager
=
FocusManager
();
...
...
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