| 1 | import { HttpStatus |
| 2 | import { DomainError } from '../../domain/errors.js'; |
| 3 |
| 4 | export class InvalidBranchNameError extends DomainError { |
| 5 | status: number = HttpStatus.BAD_REQUEST; |
| 6 |
| 7 | constructor(name: string) { |
| 8 | super(`Not a valid branch name: ${name}`); |
| 9 | } |
| 10 | } |
| 11 |
| 12 | export class BranchAlreadyExistsError extends DomainError { |
| 13 | status: number = HttpStatus.CONFLICT; |
| 14 |
| 15 | constructor(name: string) { |
| 16 | super(`A branch already exists with the name: ${name}`); |
| 17 | } |
| 18 | } |
| 19 |
| 20 | export class BranchSourceNotFoundError extends DomainError { |
| 21 | status: number = HttpStatus.NOT_FOUND; |
| 22 |
| 23 | constructor(source: string) { |
| 24 | super(`Nothing to branch from at: ${source}`); |
| 25 | } |
| 26 | } |
| 27 |
| 28 | export class DefaultBranchDeletionError extends DomainError { |
| 29 | status: number = HttpStatus.CONFLICT; |
| 30 |
| 31 | constructor(name: string) { |
| 32 | super( |
| 33 | `The default branch cannot be deleted: ${name}. Pick another default branch in the settings first.`, |
| 34 | ); |
| 35 | } |
| 36 | } |
| 37 |
| 38 | export class BranchInUseError extends DomainError { |
| 39 | status: number = HttpStatus.CONFLICT; |
| 40 |
| 41 | constructor(name: string, number: number) { |
| 42 | super( |
| 43 | `The branch ${name} is used by open pull request #${number}. Close or merge it first.`, |
| 44 | ); |
| 45 | } |
| 46 | } |