-
-
Notifications
You must be signed in to change notification settings - Fork 26
Description
In sillsdev/languageforge-lexbox#2057 we encountered a situation where the hg push operation failed due to a 500 error from the server, but everything else up to that point had gone smoothly. The result was that Chorus never called WriteException on the IProgress instance it had, so that instance still had .ErrorEncountered = false and the FieldWorks Lite code (which relies on ErrorEncountered) failed to inform the user that the Send/Receive had failed and the user should try again.
Looking into the Chorus code, I discovered this:
chorus/src/LibChorus/VcsDrivers/Mercurial/HgRepository.cs
Lines 295 to 306 in 1ab24b9
| public void PushToTarget(string targetLabel, string targetUri) | |
| { | |
| try | |
| { | |
| CheckAndUpdateHgrc(); | |
| Execute(false, _mercurialTwoCompatible,SecondsBeforeTimeoutOnRemoteOperation, "push --new-branch " + GetProxyConfigParameterString(targetUri), SurroundWithQuotes(targetUri)); | |
| } | |
| catch (Exception err) | |
| { | |
| _progress.WriteMessageWithColor("OrangeRed", | |
| $"Could not send to {ServerSettingsModel.RemovePasswordForLog(targetUri)}{Environment.NewLine}{err.Message}"); | |
| } |
The corresponding PullFromTarget code will write a progress message and then throw an exception, which eventually will result in the exception being logged with IProgress.WriteException, which will set ErrorEncountered to true. But PushToTarget doesn't throw, and doesn't call .WriteException — so FW Lite has no way of detecting this error short of brittle, error-prone things like parsing the strings Chorus writes for text like "abort: HTTP Error 500".
It would be nice if Chorus would ensure that ErrorEncountered was set to true when a push fails.