Skip to content

Commit 910a2f3

Browse files
authored
Improve exception documentation (#460)
1 parent b771b6c commit 910a2f3

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

src/Cake.AzureDevOps/Repos/PullRequest/AzureDevOpsPullRequest.cs

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,10 @@ public IEnumerable<AzureDevOpsCommit> GetCommits()
466466
/// <summary>
467467
/// Gets the files modified by the pull request.
468468
/// </summary>
469-
/// <returns>The collection of the modified files paths.</returns>
469+
/// <returns>The collection of the modified files paths or an empty list if no pull request could be found and
470+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>false</c>..</returns>
471+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
472+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
470473
public IEnumerable<FilePath> GetModifiedFiles()
471474
{
472475
if (!this.ValidatePullRequest())
@@ -526,7 +529,10 @@ public IEnumerable<FilePath> GetModifiedFiles()
526529
/// <summary>
527530
/// Gets the pull request comment threads.
528531
/// </summary>
529-
/// <returns>The list of comment threads of the pull request.</returns>
532+
/// <returns>The list of comment threads of the pull request or an empty list if no pull request could be found and
533+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>false</c>.</returns>
534+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
535+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
530536
public IEnumerable<AzureDevOpsPullRequestCommentThread> GetCommentThreads()
531537
{
532538
if (!this.ValidatePullRequest())
@@ -550,6 +556,8 @@ public IEnumerable<AzureDevOpsPullRequestCommentThread> GetCommentThreads()
550556
/// Sets the pull request comment thread status to <see cref="CommentThreadStatus.Fixed"/>.
551557
/// </summary>
552558
/// <param name="threadId">The Id of the comment thread.</param>
559+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
560+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
553561
public void ResolveCommentThread(int threadId)
554562
{
555563
this.SetCommentThreadStatus(threadId, CommentThreadStatus.Fixed);
@@ -559,6 +567,8 @@ public void ResolveCommentThread(int threadId)
559567
/// Sets the pull request comment thread to <see cref="CommentThreadStatus.Active"/>.
560568
/// </summary>
561569
/// <param name="threadId">The Id of the comment thread.</param>
570+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
571+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
562572
public void ActivateCommentThread(int threadId)
563573
{
564574
this.SetCommentThreadStatus(threadId, CommentThreadStatus.Active);
@@ -568,6 +578,8 @@ public void ActivateCommentThread(int threadId)
568578
/// Sets the pull request comment thread to <see cref="CommentThreadStatus.Closed"/>.
569579
/// </summary>
570580
/// <param name="threadId">The Id of the comment thread.</param>
581+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
582+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
571583
public void CloseCommentThread(int threadId)
572584
{
573585
this.SetCommentThreadStatus(threadId, CommentThreadStatus.Closed);
@@ -577,7 +589,10 @@ public void CloseCommentThread(int threadId)
577589
/// Creates a new comment thread with a single comment in the pull request.
578590
/// </summary>
579591
/// <param name="comment">Comment which should be added.</param>
580-
/// <returns>A newly created comment thread, or null if it can't be created.</returns>
592+
/// <returns>A newly created comment thread, or <see langword="null"/> if no pull request could be found and
593+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>false</c>..</returns>
594+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
595+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
581596
public AzureDevOpsPullRequestCommentThread CreateComment(string comment)
582597
{
583598
comment.NotNullOrWhiteSpace(nameof(comment));
@@ -606,7 +621,10 @@ public AzureDevOpsPullRequestCommentThread CreateComment(string comment)
606621
/// <param name="filePath">Path to the file to create the comment for.</param>
607622
/// <param name="lineNumber">The line number of a thread's position. Starts at 1.</param>
608623
/// <param name="offset">The character offset of a thread's position inside of a line. Starts at 0.</param>
609-
/// <returns>A newly created comment thread, or null if it can't be created.</returns>
624+
/// <returns>A newly created comment thread, or <see langword="null"/> if no pull request could be found and
625+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>false</c>..</returns>
626+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
627+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
610628
public AzureDevOpsPullRequestCommentThread CreateComment(string comment, FilePath filePath, int lineNumber, int offset)
611629
{
612630
comment.NotNullOrWhiteSpace(nameof(comment));
@@ -673,7 +691,10 @@ public void DeleteComment(AzureDevOpsComment comment)
673691
/// Updates the comment.
674692
/// </summary>
675693
/// <param name="comment">The updated comment.</param>
676-
/// <returns>The updated comment, or <c>null</c> if it can't be updated.</returns>
694+
/// <returns>The updated comment, or <see langword="null"/> if no pull request could be found and
695+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>false</c>..</returns>
696+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
697+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
677698
public AzureDevOpsComment UpdateComment(AzureDevOpsComment comment)
678699
{
679700
comment.NotNull(nameof(comment));
@@ -710,7 +731,10 @@ public AzureDevOpsComment UpdateComment(AzureDevOpsComment comment)
710731
/// Creates a new comment thread in the pull request.
711732
/// </summary>
712733
/// <param name="thread">The instance of the thread.</param>
713-
/// <returns>A newly created comment thread, or <c>null</c> if it can't be created.</returns>
734+
/// <returns>A newly created comment thread, or <see langword="null"/> if no pull request could be found and
735+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>false</c>..</returns>
736+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
737+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
714738
public AzureDevOpsPullRequestCommentThread CreateCommentThread(AzureDevOpsPullRequestCommentThread thread)
715739
{
716740
thread.NotNull(nameof(thread));
@@ -743,7 +767,10 @@ public AzureDevOpsPullRequestCommentThread CreateCommentThread(AzureDevOpsPullRe
743767
/// <summary>
744768
/// Gets the Id of the latest pull request iteration.
745769
/// </summary>
746-
/// <returns>The Id of the pull request iteration. Returns -1 in case the pull request is not valid.</returns>
770+
/// <returns>The Id of the pull request iteration or <c>-1</c> if no pull request could be found and
771+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>false</c>..</returns>
772+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
773+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
747774
/// <exception cref="AzureDevOpsException">If it is not possible to obtain a collection of <see cref="GitPullRequestIteration"/>.</exception>
748775
public int GetLatestIterationId()
749776
{
@@ -771,7 +798,10 @@ public int GetLatestIterationId()
771798
/// Gets all the pull request changes of the given iteration.
772799
/// </summary>
773800
/// <param name="iterationId">The id of the iteration.</param>
774-
/// <returns>The collection of the iteration changes of the given id. Returns an empty collection if pull request is not valid.</returns>
801+
/// <returns>The collection of the iteration changes of the given id or an empty list if no pull request could be found and
802+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>false</c>..</returns>
803+
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If pull request could not be found and
804+
/// <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
775805
public IEnumerable<AzureDevOpsPullRequestIterationChange> GetIterationChanges(int iterationId)
776806
{
777807
if (!this.ValidatePullRequest())
@@ -905,7 +935,7 @@ private void SetCommentThreadStatus(int threadId, CommentThreadStatus status)
905935
/// <summary>
906936
/// Validates if a pull request could be found.
907937
/// Depending on <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/>
908-
/// the pull request instance can be null for subsequent calls.
938+
/// the pull request instance can be <see langword="null"/> for subsequent calls.
909939
/// </summary>
910940
/// <returns>True if a valid pull request instance exists.</returns>
911941
/// <exception cref="AzureDevOpsPullRequestNotFoundException">If <see cref="AzureDevOpsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/>

0 commit comments

Comments
 (0)