| 1 | import { HttpStatus } from '@nestjs/common'; |
| 2 | import { DomainError } |
| 3 | |
| 4 | export class PullRequestNotFoundError |
| 5 | status: number |
| 6 | |
| 7 | constructor() { |
| 8 | super('Pull request not found'); |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | export class PullRequestAlreadyOpenError |
| 13 | status: number |
| 14 | |
| 15 | constructor(number: |
| 16 | super(`These branches already have an open pull request: #${number |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | export class SameBranchPullRequestError |
| 21 | status: number |
| 22 | |
| 23 | constructor() { |
| 24 | super('A pull request cannot merge a branch into itself'); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | export class UnrelatedHistoriesError |
| 29 | status: number |
| 30 | |
| 31 | constructor() { |
| 32 | super('These branches share no common history'); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | export class PullRequestNotOpenError |
| 37 | status: number |
| 38 | |
| 39 | constructor(state: |
| 40 | super(`This pull request is ${state |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | export class PullRequestConflictError |
| 45 | status: number |
| 46 | |
| 47 | constructor(readonly paths |
| 48 | super( |
| 49 | paths.length > 0 |
| 50 | ? `This pull request has conflicts in ${paths. |
| 51 | : 'This pull request has conflicts that must be resolved locally', |
| 52 | ); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | export class NothingToMergeError |
| 57 | status: number |
| 58 | |
| 59 | constructor() { |
| 60 | super('The base branch already contains every commit from the head branch'); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | export class UnrelatedRepositoriesError |
| 65 | status: number |
| 66 | |
| 67 | constructor() { |
| 68 | super( |
| 69 | 'A pull request must come from the repository itself or a fork of it', |
| 70 | ); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | /** A closed request whose head repository was deleted: its commits went with it. */ |
| 75 | export class PullRequestHeadDeletedError |
| 76 | status: number |
| 77 | |
| 78 | constructor() { |
| 79 | super( |
| 80 | 'The repository this pull request came from was deleted, and its changes with it', |
| 81 | ); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | export class PullRequestDraftError |
| 86 | status: number |
| 87 | |
| 88 | constructor() { |
| 89 | super( |
| 90 | 'This pull request is a draft; mark it ready for review before merging', |
| 91 | ); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | export class OwnPullRequestReviewError |
| 96 | status: number |
| 97 | |
| 98 | constructor() { |
| 99 | super('You cannot approve or request changes on your own pull request'); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | export class EmptyReviewError |
| 104 | status: number |
| 105 | |
| 106 | constructor() { |
| 107 | super('A comment review needs a body or at least one line comment'); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | export class ReviewLineNotInDiffError |
| 112 | status: number |
| 113 | |
| 114 | constructor(path: |
| 115 | super(`${path} |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | export class InvalidLineRangeError |
| 120 | status: number |
| 121 | |
| 122 | constructor() { |
| 123 | super('A comment on several lines must start before it ends'); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | export class SuggestionOutdatedError |
| 128 | status: number |
| 129 | |
| 130 | constructor() { |
| 131 | super( |
| 132 | 'The branch has moved on since this suggestion was made, so it no longer applies', |
| 133 | ); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | export class SuggestionNotApplicableError |
| 138 | status: number |
| 139 | |
| 140 | constructor(reason: |
| 141 | super(reason); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | export class ReviewNotFoundError |
| 146 | status: number |
| 147 | |
| 148 | constructor() { |
| 149 | super('Review not found'); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | export class ReviewCommentNotFoundError |
| 154 | status: number |
| 155 | |
| 156 | constructor() { |
| 157 | super('Review comment not found'); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | export class ReviewNotDismissableError |
| 162 | status: number |
| 163 | |
| 164 | constructor() { |
| 165 | super( |
| 166 | 'Only an approval or a request for changes that still counts can be dismissed', |
| 167 | ); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | export class PendingReviewReplyError |
| 172 | status: number |
| 173 | |
| 174 | constructor() { |
| 175 | super('Submit your review before replying to its comments'); |
| 176 | } |
| 177 | } |