Skip to content

Chorus doesn't call IProgress.WriteException on push errors #366

@rmunn

Description

@rmunn

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions