Exemplo n.º 1
0
        async private Task <bool> handleGitlabError(NewDiscussionParameters parameters, OperatorException ex)
        {
            if (ex.InternalException is GitLabRequestException rex)
            {
                var webException = rex.WebException;
                var response     = ((System.Net.HttpWebResponse)webException.Response);

                if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    // Something went wrong at the GitLab site, let's report a discussion without Position
                    return(await createMergeRequestWithoutPosition(parameters));
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    // Something went wrong at the GitLab site, let's report a discussion without Position
                    await cleanupBadNotes(parameters);

                    return(await createMergeRequestWithoutPosition(parameters));
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        async private Task <bool> handleGitlabError(NewDiscussionParameters parameters, OperatorException ex,
                                                    bool revertOnError)
        {
            if (ex == null)
            {
                Trace.TraceWarning("[DiscussionCreator] An exception with null value was caught");
                return(false);
            }

            if (parameters.Position == null)
            {
                Trace.TraceWarning("[DiscussionCreator] Unexpected situation at GitLab");
                return(false);
            }

            if (ex.InnerException is GitLabRequestException rx)
            {
                if (rx.InnerException is System.Net.WebException wx)
                {
                    if (wx.Response == null)
                    {
                        Trace.TraceWarning("[DiscussionCreator] Null Response in WebException");
                        return(false);
                    }

                    System.Net.HttpWebResponse response = wx.Response as System.Net.HttpWebResponse;
                    if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
                    {
                        // Something went wrong at the GitLab, let's report a discussion without Position
                        return(await createMergeRequestWithoutPosition(parameters));
                    }
                    else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                    {
                        // Something went wrong at the GitLab
                        if (revertOnError)
                        {
                            await deleteMostRecentNote(parameters);

                            return(await createMergeRequestWithoutPosition(parameters));
                        }
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 3
0
 virtual protected void PostOnOperatorException(Exception e)
 {
     OperatorException?.Invoke(new ModelingOpException(this, e));
 }