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
7745dd73
Commit
7745dd73
authored
Oct 06, 2016
by
Dan Rubel
Committed by
GitHub
Oct 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve flutter tool error message for download problems (#6238)
parent
1b9c1bd2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
2 deletions
+35
-2
executable.dart
packages/flutter_tools/lib/executable.dart
+11
-0
common.dart
packages/flutter_tools/lib/src/base/common.dart
+14
-0
net.dart
packages/flutter_tools/lib/src/base/net.dart
+10
-2
No files found.
packages/flutter_tools/lib/executable.dart
View file @
7745dd73
...
...
@@ -8,6 +8,7 @@ import 'dart:io';
import
'package:args/command_runner.dart'
;
import
'package:stack_trace/stack_trace.dart'
;
import
'src/base/common.dart'
;
import
'src/base/context.dart'
;
import
'src/base/logger.dart'
;
import
'src/base/process.dart'
;
...
...
@@ -102,6 +103,16 @@ Future<Null> main(List<String> args) async {
);
// Argument error exit code.
_exit
(
64
);
}
else
if
(
error
is
ToolExit
)
{
stderr
.
writeln
(
error
.
message
);
if
(
verbose
)
{
stderr
.
writeln
();
stderr
.
writeln
(
chain
.
terse
.
toString
());
stderr
.
writeln
();
}
stderr
.
writeln
(
'If this problem persists, please report the problem at'
);
stderr
.
writeln
(
'https://github.com/flutter/flutter/issues/new'
);
_exit
(
error
.
exitCode
??
65
);
}
else
if
(
error
is
ProcessExit
)
{
// We've caught an exit code.
_exit
(
error
.
exitCode
);
...
...
packages/flutter_tools/lib/src/base/common.dart
View file @
7745dd73
...
...
@@ -5,3 +5,17 @@
const
int
kDefaultObservatoryPort
=
8100
;
const
int
kDefaultDiagnosticPort
=
8101
;
const
int
kDefaultDrivePort
=
8183
;
/// Specialized exception for expected situations
/// where the tool should exit with a clear message to the user
/// and no stack trace unless the --verbose option is specified.
/// For example: network errors
class
ToolExit
implements
Exception
{
ToolExit
(
this
.
message
,
{
this
.
exitCode
});
final
String
message
;
final
int
exitCode
;
@override
String
toString
()
=>
"Exception:
$message
"
;
}
packages/flutter_tools/lib/src/base/net.dart
View file @
7745dd73
...
...
@@ -6,6 +6,9 @@ import 'dart:async';
import
'dart:io'
;
import
'../globals.dart'
;
import
'common.dart'
;
const
int
kNetworkProblemExitCode
=
50
;
/// Download a file from the given URL and return the bytes.
Future
<
List
<
int
>>
fetchUrl
(
Uri
url
)
async
{
...
...
@@ -16,8 +19,13 @@ Future<List<int>> fetchUrl(Uri url) async {
HttpClientResponse
response
=
await
request
.
close
();
printTrace
(
'Received response statusCode=
${response.statusCode}
'
);
if
(
response
.
statusCode
!=
200
)
throw
new
Exception
(
response
.
reasonPhrase
);
if
(
response
.
statusCode
!=
200
)
{
throw
new
ToolExit
(
'Download failed:
$url
\n
'
' because (
${response.statusCode}
)
${response.reasonPhrase}
'
,
exitCode:
kNetworkProblemExitCode
,
);
}
BytesBuilder
responseBody
=
new
BytesBuilder
(
copy:
false
);
await
for
(
List
<
int
>
chunk
in
response
)
...
...
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