From 356771fed1235c3abcce3586e3d8f51ff904c22a Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Wed, 21 Aug 2019 17:30:02 +0200 Subject: [PATCH] Remove code duplication --- lib/screens/githostsetup_autoconfigure.dart | 35 +++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/lib/screens/githostsetup_autoconfigure.dart b/lib/screens/githostsetup_autoconfigure.dart index 87b1119f..49021eff 100644 --- a/lib/screens/githostsetup_autoconfigure.dart +++ b/lib/screens/githostsetup_autoconfigure.dart @@ -89,35 +89,30 @@ class GitHostSetupAutoConfigureState extends State { } Settings.instance.save(); } on GitHostException catch (e) { - Fimber.d("GitHostSetupAutoConfigure: " + e.toString()); - setState(() { - errorMessage = widget.gitHostType.toString() + ": " + e.toString(); - getAnalytics().logEvent( - name: "githostsetup_error", - parameters: { - 'errorMessage': errorMessage, - }, - ); - }); + _handleGitHostException(e); return; } widget.onDone(repo.cloneUrl); }); gitHost.launchOAuthScreen(); } on GitHostException catch (e) { - Fimber.d("GitHostSetupAutoConfigure: " + e.toString()); - setState(() { - errorMessage = widget.gitHostType.toString() + ": " + e.toString(); - getAnalytics().logEvent( - name: "githostsetup_error", - parameters: { - 'errorMessage': errorMessage, - }, - ); - }); + _handleGitHostException(e); } } + void _handleGitHostException(GitHostException e) { + Fimber.d("GitHostSetupAutoConfigure: " + e.toString()); + setState(() { + errorMessage = widget.gitHostType.toString() + ": " + e.toString(); + getAnalytics().logEvent( + name: "githostsetup_error", + parameters: { + 'errorMessage': errorMessage, + }, + ); + }); + } + @override Widget build(BuildContext context) { if (_configuringStarted) {