[flutter tools] Move _informUserOfCrash into crash_reporting.dart (#55614)
This commit is contained in:
@@ -26,15 +26,73 @@ const String _kStackTraceFileField = 'DartError';
|
||||
/// it must be supplied in the request.
|
||||
const String _kStackTraceFilename = 'stacktrace_file';
|
||||
|
||||
class CrashDetails {
|
||||
CrashDetails({
|
||||
@required this.command,
|
||||
@required this.error,
|
||||
@required this.stackTrace,
|
||||
@required this.doctorText,
|
||||
});
|
||||
|
||||
final String command;
|
||||
final dynamic error;
|
||||
final StackTrace stackTrace;
|
||||
final String doctorText;
|
||||
}
|
||||
|
||||
/// Reports information about the crash to the user.
|
||||
class CrashReporter {
|
||||
CrashReporter({
|
||||
@required FileSystem fileSystem,
|
||||
@required Logger logger,
|
||||
@required FlutterProjectFactory flutterProjectFactory,
|
||||
@required HttpClient client,
|
||||
}) : _fileSystem = fileSystem,
|
||||
_logger = logger,
|
||||
_flutterProjectFactory = flutterProjectFactory,
|
||||
_client = client;
|
||||
|
||||
final FileSystem _fileSystem;
|
||||
final Logger _logger;
|
||||
final FlutterProjectFactory _flutterProjectFactory;
|
||||
final HttpClient _client;
|
||||
|
||||
/// Prints instructions for filing a bug about the crash.
|
||||
Future<void> informUser(CrashDetails details, File crashFile) async {
|
||||
_logger.printError('A crash report has been written to ${crashFile.path}.');
|
||||
_logger.printStatus('This crash may already be reported. Check GitHub for similar crashes.', emphasis: true);
|
||||
|
||||
final String similarIssuesURL = GitHubTemplateCreator.toolCrashSimilarIssuesURL(details.error.toString());
|
||||
_logger.printStatus('$similarIssuesURL\n', wrap: false);
|
||||
_logger.printStatus('To report your crash to the Flutter team, first read the guide to filing a bug.', emphasis: true);
|
||||
_logger.printStatus('https://flutter.dev/docs/resources/bug-reports\n', wrap: false);
|
||||
|
||||
_logger.printStatus('Create a new GitHub issue by pasting this link into your browser and completing the issue template. Thank you!', emphasis: true);
|
||||
|
||||
final GitHubTemplateCreator gitHubTemplateCreator = GitHubTemplateCreator(
|
||||
fileSystem: _fileSystem,
|
||||
logger: _logger,
|
||||
flutterProjectFactory: _flutterProjectFactory,
|
||||
client: _client,
|
||||
);
|
||||
|
||||
final String gitHubTemplateURL = await gitHubTemplateCreator.toolCrashIssueTemplateGitHubURL(
|
||||
details.command,
|
||||
details.error,
|
||||
details.stackTrace,
|
||||
details.doctorText,
|
||||
);
|
||||
_logger.printStatus('$gitHubTemplateURL\n', wrap: false);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends crash reports to Google.
|
||||
///
|
||||
/// There are two ways to override the behavior of this class:
|
||||
///
|
||||
/// * Define a `FLUTTER_CRASH_SERVER_BASE_URL` environment variable that points
|
||||
/// to a custom crash reporting server. This is useful if your development
|
||||
/// environment is behind a firewall and unable to send crash reports to
|
||||
/// Google, or when you wish to use your own server for collecting crash
|
||||
/// reports from Flutter Tools.
|
||||
/// To override the behavior of this class, define a
|
||||
/// `FLUTTER_CRASH_SERVER_BASE_URL` environment variable that points to a custom
|
||||
/// crash reporting server. This is useful if your development environment is
|
||||
/// behind a firewall and unable to send crash reports to Google, or when you
|
||||
/// wish to use your own server for collecting crash reports from Flutter Tools.
|
||||
class CrashReportSender {
|
||||
CrashReportSender({
|
||||
@required http.Client client,
|
||||
|
||||
Reference in New Issue
Block a user