Remove code duplication

This commit is contained in:
Vishesh Handa
2019-08-21 17:30:02 +02:00
parent e98262b5ba
commit 356771fed1

View File

@ -89,35 +89,30 @@ class GitHostSetupAutoConfigureState extends State<GitHostSetupAutoConfigure> {
} }
Settings.instance.save(); Settings.instance.save();
} on GitHostException catch (e) { } on GitHostException catch (e) {
Fimber.d("GitHostSetupAutoConfigure: " + e.toString()); _handleGitHostException(e);
setState(() {
errorMessage = widget.gitHostType.toString() + ": " + e.toString();
getAnalytics().logEvent(
name: "githostsetup_error",
parameters: <String, dynamic>{
'errorMessage': errorMessage,
},
);
});
return; return;
} }
widget.onDone(repo.cloneUrl); widget.onDone(repo.cloneUrl);
}); });
gitHost.launchOAuthScreen(); gitHost.launchOAuthScreen();
} on GitHostException catch (e) { } on GitHostException catch (e) {
Fimber.d("GitHostSetupAutoConfigure: " + e.toString()); _handleGitHostException(e);
setState(() {
errorMessage = widget.gitHostType.toString() + ": " + e.toString();
getAnalytics().logEvent(
name: "githostsetup_error",
parameters: <String, dynamic>{
'errorMessage': errorMessage,
},
);
});
} }
} }
void _handleGitHostException(GitHostException e) {
Fimber.d("GitHostSetupAutoConfigure: " + e.toString());
setState(() {
errorMessage = widget.gitHostType.toString() + ": " + e.toString();
getAnalytics().logEvent(
name: "githostsetup_error",
parameters: <String, dynamic>{
'errorMessage': errorMessage,
},
);
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_configuringStarted) { if (_configuringStarted) {