mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-02 02:45:32 +00:00
Make new merge exceptions inherit from 'Octokit.ApiException'
Affect 'Octokit.PullRequestNotMergeableException' and 'Octokit.PullRequestMismatchException'
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Octokit
|
||||
@@ -10,26 +13,39 @@ namespace Octokit
|
||||
#if !NETFX_CORE
|
||||
[Serializable]
|
||||
#endif
|
||||
public class PullRequestNotMergeableException : Exception
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class PullRequestNotMergeableException : ApiException
|
||||
{
|
||||
public PullRequestNotMergeableException()
|
||||
: base("The pull request is not in a mergeable state")
|
||||
/// <summary>
|
||||
/// Constructs an instance of the <see cref="Octokit.PullRequestNotMergeableException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="response">The HTTP payload from the server</param>
|
||||
public PullRequestNotMergeableException(IResponse response) : this(response, null)
|
||||
{
|
||||
}
|
||||
|
||||
public PullRequestNotMergeableException(string message)
|
||||
: base(message)
|
||||
/// <summary>
|
||||
/// Constructs an instance of the <see cref="Octokit.PullRequestNotMergeableException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="response">The HTTP payload from the server</param>
|
||||
/// <param name="innerException">The inner exception</param>
|
||||
public PullRequestNotMergeableException(IResponse response, Exception innerException)
|
||||
: base(response, innerException)
|
||||
{
|
||||
Debug.Assert(response != null && response.StatusCode == HttpStatusCode.MethodNotAllowed,
|
||||
"PullRequestNotMergeableException created with the wrong HTTP status code");
|
||||
}
|
||||
|
||||
public PullRequestNotMergeableException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
public override string Message
|
||||
{
|
||||
//https://developer.github.com/v3/pulls/#response-if-merge-cannot-be-performed
|
||||
get { return ApiErrorMessageSafe ?? "Pull Request is not mergeable"; }
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
/// <summary>
|
||||
/// Constructs an instance of PullRequestNotMergeableException.
|
||||
/// Constructs an instance of <see cref="Octokit.PullRequestNotMergeableException"/>.
|
||||
/// </summary>
|
||||
/// <param name="info">
|
||||
/// The <see cref="SerializationInfo"/> that holds the
|
||||
|
||||
Reference in New Issue
Block a user