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
663dc1d7
Unverified
Commit
663dc1d7
authored
Aug 22, 2019
by
Zachary Anderson
Committed by
GitHub
Aug 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Teach crash reporter about HttpException (#39005)
parent
0249050f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
1 deletion
+50
-1
crash_reporting.dart
...ages/flutter_tools/lib/src/reporting/crash_reporting.dart
+1
-1
crash_reporting_test.dart
...lutter_tools/test/general.shard/crash_reporting_test.dart
+49
-0
No files found.
packages/flutter_tools/lib/src/reporting/crash_reporting.dart
View file @
663dc1d7
...
@@ -127,7 +127,7 @@ class CrashReportSender {
...
@@ -127,7 +127,7 @@ class CrashReportSender {
printError
(
'Failed to send crash report. Server responded with HTTP status code
${resp.statusCode}
'
);
printError
(
'Failed to send crash report. Server responded with HTTP status code
${resp.statusCode}
'
);
}
}
}
catch
(
sendError
,
sendStackTrace
)
{
}
catch
(
sendError
,
sendStackTrace
)
{
if
(
sendError
is
SocketException
)
{
if
(
sendError
is
SocketException
||
sendError
is
HttpException
)
{
printError
(
'Failed to send crash report due to a network error:
$sendError
'
);
printError
(
'Failed to send crash report due to a network error:
$sendError
'
);
}
else
{
}
else
{
// If the sender itself crashes, just print. We did our best.
// If the sender itself crashes, just print. We did our best.
...
...
packages/flutter_tools/test/general.shard/crash_reporting_test.dart
View file @
663dc1d7
...
@@ -59,6 +59,48 @@ void main() {
...
@@ -59,6 +59,48 @@ void main() {
Stdio:
()
=>
const
_NoStderr
(),
Stdio:
()
=>
const
_NoStderr
(),
});
});
testUsingContext
(
'should print an explanatory message when there is a SocketException'
,
()
async
{
final
Completer
<
int
>
exitCodeCompleter
=
Completer
<
int
>();
setExitFunctionForTests
((
int
exitCode
)
{
exitCodeCompleter
.
complete
(
exitCode
);
});
CrashReportSender
.
initializeWith
(
CrashingCrashReportSender
(
const
SocketException
(
'no internets'
)));
unawaited
(
tools
.
run
(
<
String
>[
'crash'
],
<
FlutterCommand
>[
_CrashAsyncCommand
()],
reportCrashes:
true
,
flutterVersion:
'test-version'
,
));
expect
(
await
exitCodeCompleter
.
future
,
1
);
expect
(
testLogger
.
errorText
,
contains
(
'Failed to send crash report due to a network error'
));
},
overrides:
<
Type
,
Generator
>{
Stdio:
()
=>
const
_NoStderr
(),
});
testUsingContext
(
'should print an explanatory message when there is an HttpException'
,
()
async
{
final
Completer
<
int
>
exitCodeCompleter
=
Completer
<
int
>();
setExitFunctionForTests
((
int
exitCode
)
{
exitCodeCompleter
.
complete
(
exitCode
);
});
CrashReportSender
.
initializeWith
(
CrashingCrashReportSender
(
const
HttpException
(
'no internets'
)));
unawaited
(
tools
.
run
(
<
String
>[
'crash'
],
<
FlutterCommand
>[
_CrashAsyncCommand
()],
reportCrashes:
true
,
flutterVersion:
'test-version'
,
));
expect
(
await
exitCodeCompleter
.
future
,
1
);
expect
(
testLogger
.
errorText
,
contains
(
'Failed to send crash report due to a network error'
));
},
overrides:
<
Type
,
Generator
>{
Stdio:
()
=>
const
_NoStderr
(),
});
testUsingContext
(
'should send crash reports when async throws'
,
()
async
{
testUsingContext
(
'should send crash reports when async throws'
,
()
async
{
final
Completer
<
int
>
exitCodeCompleter
=
Completer
<
int
>();
final
Completer
<
int
>
exitCodeCompleter
=
Completer
<
int
>();
setExitFunctionForTests
((
int
exitCode
)
{
setExitFunctionForTests
((
int
exitCode
)
{
...
@@ -270,6 +312,13 @@ class MockCrashReportSender extends MockClient {
...
@@ -270,6 +312,13 @@ class MockCrashReportSender extends MockClient {
static
int
sendCalls
=
0
;
static
int
sendCalls
=
0
;
}
}
class
CrashingCrashReportSender
extends
MockClient
{
CrashingCrashReportSender
(
Object
exception
)
:
super
((
Request
request
)
async
{
throw
exception
;
});
}
/// Throws a random error to simulate a CLI crash.
/// Throws a random error to simulate a CLI crash.
class
_CrashCommand
extends
FlutterCommand
{
class
_CrashCommand
extends
FlutterCommand
{
...
...
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