private static bool areConflictsFoundAtMerge(MergeRequestEditorException ex)
 {
     if (ex.InnerException != null && (ex.InnerException is GitLabRequestException))
     {
         GitLabRequestException rx = ex.InnerException as GitLabRequestException;
         if (rx.InnerException is System.Net.WebException wx && wx.Response != null)
         {
             System.Net.HttpWebResponse response = wx.Response as System.Net.HttpWebResponse;
             return(response.StatusCode == System.Net.HttpStatusCode.NotAcceptable);
         }
     }
     return(false);
 }
        private void reportErrorToUser(MergeRequestEditorException ex)
        {
            if (ex is MergeRequestEditorCancelledException)
            {
                return;
            }

            void showDialogAndLogError(string message = "Unknown")
            {
                string defaultMessage = "GitLab could not perform a requested operation. Reason: ";

                MessageBox.Show(defaultMessage + message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                traceError(defaultMessage + message);
            };

            if (ex.InnerException != null && (ex.InnerException is GitLabRequestException))
            {
                GitLabRequestException rx = ex.InnerException as GitLabRequestException;
                if (rx.InnerException is System.Net.WebException wx && wx.Response != null)
                {
                    System.Net.HttpWebResponse response = wx.Response as System.Net.HttpWebResponse;
                    switch (response.StatusCode)
                    {
                    case System.Net.HttpStatusCode.MethodNotAllowed:
                        showDialogAndLogError("Merge request in its current state cannot be merged.");
                        return;

                    case System.Net.HttpStatusCode.Unauthorized:
                    case System.Net.HttpStatusCode.Forbidden:
                        showDialogAndLogError("Access denied or source branch does not exist");
                        return;

                    case System.Net.HttpStatusCode.BadRequest:
                        showDialogAndLogError("Bad parameters");
                        return;
                    }
                }
            }

            showDialogAndLogError();
        }