diff --git a/src/Cake.Tfs/PullRequest/TfsPullRequest.cs b/src/Cake.Tfs/PullRequest/TfsPullRequest.cs
index 7de18d8..35704d2 100644
--- a/src/Cake.Tfs/PullRequest/TfsPullRequest.cs
+++ b/src/Cake.Tfs/PullRequest/TfsPullRequest.cs
@@ -25,7 +25,7 @@ public sealed class TfsPullRequest
///
/// The Cake log context.
/// Settings for accessing TFS.
- /// If
+ /// If
/// is set to true and no pull request could be found.
public TfsPullRequest(ICakeLog log, TfsPullRequestSettings settings)
{
@@ -90,7 +90,7 @@ public TfsPullRequest(ICakeLog log, TfsPullRequestSettings settings)
{
if (this.settings.ThrowExceptionIfPullRequestCouldNotBeFound)
{
- throw new TfsException("Could not find pull request");
+ throw new TfsPullRequestNotFoundException("Pull request not found");
}
this.log.Warning("Could not find pull request");
@@ -141,7 +141,7 @@ public TfsPullRequest(ICakeLog log, TfsPullRequestSettings settings)
/// Returns if no pull request could be found and
/// is set to false.
///
- /// If pull request could not be found and
+ /// If pull request could not be found and
/// is set to true.
public Guid RepositoryId
{
@@ -161,7 +161,7 @@ public Guid RepositoryId
/// Returns 0 if no pull request could be found and
/// is set to false.
///
- /// If pull request could not be found and
+ /// If pull request could not be found and
/// is set to true.
public int PullRequestId
{
@@ -181,7 +181,7 @@ public int PullRequestId
/// Returns 0 if no pull request could be found and
/// is set to false.
///
- /// If pull request could not be found and
+ /// If pull request could not be found and
/// is set to true.
public int CodeReviewId
{
@@ -201,7 +201,7 @@ public int CodeReviewId
/// Returns if no pull request could be found and
/// is set to false.
///
- /// If pull request could not be found and
+ /// If pull request could not be found and
/// is set to true.
public string LastSourceCommitId
{
@@ -220,6 +220,8 @@ public string LastSourceCommitId
/// Votes for the pullrequest.
///
/// The vote for the pull request.
+ /// If pull request could not be found and
+ /// is set to true.
public void Vote(TfsPullRequestVote vote)
{
if (!this.ValidatePullRequest())
@@ -249,9 +251,9 @@ public void Vote(TfsPullRequestVote vote)
/// the pull request instance can be null for subsequent calls.
///
/// True if a valid pull request instance exists.
- /// If
+ /// If
/// is set to true and no pull request could be found.
- public bool ValidatePullRequest()
+ private bool ValidatePullRequest()
{
if (this.HasPullRequestLoaded)
{
@@ -260,7 +262,7 @@ public bool ValidatePullRequest()
if (this.settings.ThrowExceptionIfPullRequestCouldNotBeFound)
{
- throw new TfsException("Could not find pull request");
+ throw new TfsPullRequestNotFoundException("Pull request not found");
}
this.log.Verbose("Skipping, since no pull request instance could be found.");
diff --git a/src/Cake.Tfs/PullRequest/TfsPullRequestNotFoundException.cs b/src/Cake.Tfs/PullRequest/TfsPullRequestNotFoundException.cs
new file mode 100644
index 0000000..b3eb35d
--- /dev/null
+++ b/src/Cake.Tfs/PullRequest/TfsPullRequestNotFoundException.cs
@@ -0,0 +1,52 @@
+namespace Cake.Tfs.PullRequest
+{
+ using System;
+ using System.Runtime.Serialization;
+
+ ///
+ /// Represents an error if a pull request was not found.
+ ///
+ [Serializable]
+ public class TfsPullRequestNotFoundException : TfsException
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public TfsPullRequestNotFoundException()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class with a specified error message.
+ ///
+ /// The message that describes the error.
+ public TfsPullRequestNotFoundException(string message)
+ : base(message)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class with a specified error message
+ /// and a reference to the inner exception that is the cause of this exception.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null
+ /// reference if no inner exception is specified.
+ public TfsPullRequestNotFoundException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class with serialized data.
+ ///
+ /// The that holds the serialized object data about
+ /// the exception being thrown.
+ /// The that contains contextual information about
+ /// the source or destination.
+ protected TfsPullRequestNotFoundException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ {
+ }
+ }
+}
diff --git a/src/Cake.Tfs/TfsAliases.PullRequest.cs b/src/Cake.Tfs/TfsAliases.PullRequest.cs
index cd1d533..24fec9b 100644
--- a/src/Cake.Tfs/TfsAliases.PullRequest.cs
+++ b/src/Cake.Tfs/TfsAliases.PullRequest.cs
@@ -34,7 +34,7 @@ public static partial class TfsAliases
/// Description of the pull request.
/// Returns null if pull request could not be found and
/// is set to false.
- /// If pull request could not be found and
+ /// If pull request could not be found and
/// is set to true.
[CakeMethodAlias]
[CakeAliasCategory("Pull Request")]
@@ -78,6 +78,8 @@ public static TfsPullRequest TfsPullRequest(
/// ]]>
///
///
+ /// If pull request could not be found and
+ /// is set to true.
[CakeMethodAlias]
[CakeAliasCategory("Pull Request")]
public static void TfsPullRequestVote(
@@ -88,8 +90,7 @@ public static void TfsPullRequestVote(
context.NotNull(nameof(context));
settings.NotNull(nameof(settings));
- var pullRequest = new TfsPullRequest(context.Log, settings);
- pullRequest.Vote(vote);
+ new TfsPullRequest(context.Log, settings).Vote(vote);
}
}
}
\ No newline at end of file