| 1 | import { HttpStatus } from '@nestjs/common'; |
| 2 | |
| 3 | import { DomainError } from '../../domain/errors.js'; |
| 4 | |
| 5 | export class ReleaseNotFoundError extends DomainError { |
| 6 | status: number = HttpStatus.NOT_FOUND; |
| 7 | |
| 8 | constructor() { |
| 9 | super('Release not found'); |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | export class ReleaseAlreadyExistsError extends DomainError { |
| 14 | status: number = HttpStatus.CONFLICT; |
| 15 | |
| 16 | constructor(tagName: string) { |
| 17 | super(`A release already exists for the tag: ${tagName}`); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | export class InvalidTagNameError extends DomainError { |
| 22 | status: number = HttpStatus.BAD_REQUEST; |
| 23 | |
| 24 | constructor(tagName: string) { |
| 25 | super(`Not a valid tag name: ${tagName}`); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | export class TagTargetNotFoundError extends DomainError { |
| 30 | status: number = HttpStatus.NOT_FOUND; |
| 31 | |
| 32 | constructor(target: string) { |
| 33 | super(`Nothing to tag at: ${target}`); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | export class ReleaseAssetNotFoundError extends DomainError { |
| 38 | status: number = HttpStatus.NOT_FOUND; |
| 39 | |
| 40 | constructor() { |
| 41 | super('Release asset not found'); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | export class ReleaseAssetExistsError extends DomainError { |
| 46 | status: number = HttpStatus.CONFLICT; |
| 47 | |
| 48 | constructor(name: string) { |
| 49 | super(`This release already has an asset named: ${name}`); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | export class InvalidAssetNameError extends DomainError { |
| 54 | status: number = HttpStatus.BAD_REQUEST; |
| 55 | |
| 56 | constructor(name: string) { |
| 57 | super(`Not a valid file name: ${name}`); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | export class ReleaseAssetTooLargeError extends DomainError { |
| 62 | status: number = HttpStatus.PAYLOAD_TOO_LARGE; |
| 63 | |
| 64 | constructor(limit: string) { |
| 65 | super(`Release assets are limited to ${limit}`); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | export class UploadNotOctetStreamError extends DomainError { |
| 70 | status: number = HttpStatus.UNSUPPORTED_MEDIA_TYPE; |
| 71 | |
| 72 | constructor() { |
| 73 | super( |
| 74 | 'Send the file as application/octet-stream, and its own type as the `type` query parameter', |
| 75 | ); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | export class TagNotFoundError extends DomainError { |
| 80 | status: number = HttpStatus.NOT_FOUND; |
| 81 | |
| 82 | constructor(tagName: string) { |
| 83 | super(`Tag not found: ${tagName}`); |
| 84 | } |
| 85 | } |