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
b39a9473
Unverified
Commit
b39a9473
authored
Mar 17, 2022
by
Danny Tuppeny
Committed by
GitHub
Mar 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle Flutter.Error events and disable structure errors for noDebug mode (#100149)
parent
6ec0b835
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
0 deletions
+61
-0
flutter_adapter.dart
...flutter_tools/lib/src/debug_adapters/flutter_adapter.dart
+24
-0
flutter_adapter_test.dart
...integration.shard/debug_adapter/flutter_adapter_test.dart
+34
-0
test_support.dart
...ls/test/integration.shard/debug_adapter/test_support.dart
+3
-0
No files found.
packages/flutter_tools/lib/src/debug_adapters/flutter_adapter.dart
View file @
b39a9473
...
...
@@ -223,11 +223,29 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
case
'Flutter.ServiceExtensionStateChanged'
:
_sendServiceExtensionStateChanged
(
event
.
extensionData
);
break
;
case
'Flutter.Error'
:
_handleFlutterErrorEvent
(
event
.
extensionData
);
break
;
}
break
;
}
}
/// Sends OutputEvents to the client for a Flutter.Error event.
void
_handleFlutterErrorEvent
(
vm
.
ExtensionData
?
data
)
{
final
Map
<
String
,
dynamic
>?
errorData
=
data
?.
data
;
if
(
errorData
==
null
)
{
return
;
}
final
String
errorText
=
(
errorData
[
'renderedErrorText'
]
as
String
?)
??
(
errorData
[
'description'
]
as
String
?)
// We should never not error text, but if we do at least send something
// so it's not just completely silent.
??
'Unknown error in Flutter.Error event'
;
sendOutput
(
'stderr'
,
'
$errorText
\n
'
);
}
/// Called by [launchRequest] to request that we actually start the app to be run/debugged.
///
/// For debugging, this should start paused, connect to the VM Service, set
...
...
@@ -240,6 +258,12 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
'run'
,
'--machine'
,
if
(
enableDebugger
)
'--start-paused'
,
// Structured errors are enabled by default, but since we don't connect
// the VM Service for noDebug, we need to disable them so that error text
// is sent to stderr. Otherwise the user will not see any exception text
// (because nobody is listening for Flutter.Error events).
if
(!
enableDebugger
)
'--dart-define=flutter.inspector.structuredErrors=false'
,
];
await
_startProcess
(
...
...
packages/flutter_tools/test/integration.shard/debug_adapter/flutter_adapter_test.dart
View file @
b39a9473
...
...
@@ -115,6 +115,40 @@ void main() {
expect
(
output
,
contains
(
'Exited (1)'
));
});
/// Helper that tests exception output in either debug or noDebug mode.
Future
<
void
>
testExceptionOutput
({
required
bool
noDebug
})
async
{
final
BasicProjectThatThrows
project
=
BasicProjectThatThrows
();
await
project
.
setUpIn
(
tempDir
);
final
List
<
OutputEventBody
>
outputEvents
=
await
dap
.
client
.
collectAllOutput
(
launch:
()
{
// Terminate the app after we see the exception because otherwise
// it will keep running and `collectAllOutput` won't end.
dap
.
client
.
output
.
firstWhere
((
String
output
)
=>
output
.
contains
(
endOfErrorOutputMarker
))
.
then
((
_
)
=>
dap
.
client
.
terminate
());
return
dap
.
client
.
launch
(
noDebug:
noDebug
,
cwd:
project
.
dir
.
path
,
toolArgs:
<
String
>[
'-d'
,
'flutter-tester'
],
);
});
final
String
output
=
_uniqueOutputLines
(
outputEvents
);
final
List
<
String
>
outputLines
=
output
.
split
(
'
\n
'
);
expect
(
outputLines
,
containsAllInOrder
(<
String
>[
'══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════'
,
'The following _Exception was thrown building App(dirty):'
,
'Exception: c'
,
'The relevant error-causing widget was:'
,
]));
expect
(
output
,
contains
(
'App:
${Uri.file(project.dir.path)}
/lib/main.dart:24:12'
));
}
testWithoutContext
(
'correctly outputs exceptions in debug mode'
,
()
=>
testExceptionOutput
(
noDebug:
false
));
testWithoutContext
(
'correctly outputs exceptions in noDebug mode'
,
()
=>
testExceptionOutput
(
noDebug:
true
));
testWithoutContext
(
'can hot reload'
,
()
async
{
final
BasicProject
project
=
BasicProject
();
await
project
.
setUpIn
(
tempDir
);
...
...
packages/flutter_tools/test/integration.shard/debug_adapter/test_support.dart
View file @
b39a9473
...
...
@@ -33,6 +33,9 @@ final bool useInProcessDap = Platform.environment['DAP_TEST_INTERNAL'] == 'true'
/// Service traffic (wrapped in a custom 'dart.log' event).
final
bool
verboseLogging
=
Platform
.
environment
[
'DAP_TEST_VERBOSE'
]
==
'true'
;
const
String
startOfErrorOutputMarker
=
'══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════'
;
const
String
endOfErrorOutputMarker
=
'════════════════════════════════════════════════════════════════════════════════════════════════════'
;
/// Expects the lines in [actual] to match the relevant matcher in [expected],
/// ignoring differences in line endings and trailing whitespace.
void
expectLines
(
...
...
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