Commits

Christian Specht  committed bca9fcb

catch pulling timeout and display proper error message

  • Participants
  • Parent commits d7e2ce4

Comments (0)

Files changed (4)

File src/BitbucketBackup/MercurialRepository.cs

                 throw new InvalidOperationException("You need to call Init() first!");
             }
 
-            this.repo.Pull(this.remoteuri, new PullCommand().WithUpdate(false).WithTimeout(this.config.PullTimeout));
+            try
+            {
+                this.repo.Pull(this.remoteuri, new PullCommand().WithUpdate(false).WithTimeout(this.config.PullTimeout));
+            }
+            catch (MercurialException ex)
+            {
+                // catch only timeouts, re-throw everything else
+                if (ex.Message == "The executable did not complete within the allotted time")
+                {
+                    throw new ClientException(String.Format(Resources.PullTimeoutExceeded, this.config.PullTimeout), null);
+                }
+                
+                throw;
+            }
         }
     }
 }

File src/BitbucketBackup/Resources.Designer.cs

         }
         
         /// <summary>
+        ///   Sucht eine lokalisierte Zeichenfolge, die Timeout for pulling exceeded! ({0} seconds)  ähnelt.
+        /// </summary>
+        internal static string PullTimeoutExceeded {
+            get {
+                return ResourceManager.GetString("PullTimeoutExceeded", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Sucht eine lokalisierte Zeichenfolge, die Press &lt;SPACE&gt; in the next {0} seconds to re-enter your settings! ähnelt.
         /// </summary>
         internal static string SettingsPrompt {

File src/BitbucketBackup/Resources.de.resx

   <data name="PressEnter" xml:space="preserve">
     <value>Drücken Sie &lt;ENTER&gt;, um das Programm zu beenden!</value>
   </data>
+  <data name="PullTimeoutExceeded" xml:space="preserve">
+    <value>Timeout für Pulls überschritten! ({0} Sekunden)</value>
+  </data>
   <data name="SettingsPrompt" xml:space="preserve">
     <value>Drücken Sie &lt;LEERTASTE&gt; in den nächsten {0} Sekunden,
 um Ihre Einstellungen zu ändern!</value>

File src/BitbucketBackup/Resources.resx

   <data name="InputPullTimeoutInvalid" xml:space="preserve">
     <value>Timeout for pulling must be an integer value greater than zero!</value>
   </data>
+  <data name="PullTimeoutExceeded" xml:space="preserve">
+    <value>Timeout for pulling exceeded! ({0} seconds) </value>
+  </data>
 </root>