import { IsString } from 'class-validator';
import { NotAcceptableError, NotFoundError } from 'routing-controllers';

/**
 * Error to throw when a card couldn't be found.
 */
export class RunnerCardNotFoundError extends NotFoundError {
	@IsString()
	name = "RunnerCardNotFoundError"

	@IsString()
	message = "Card not found!"
}

/**
 * Error to throw when two cards' ids don't match.
 * Usually occurs when a user tries to change a card's id.
 */
export class RunnerCardIdsNotMatchingError extends NotAcceptableError {
	@IsString()
	name = "RunnerCardIdsNotMatchingError"

	@IsString()
	message = "The ids don't match! \n And if you wanted to change a cards's id: This isn't allowed"
}

/**
 * Error to throw when a card still has scans associated.
 */
export class RunnerCardHasScansError extends NotAcceptableError {
	@IsString()
	name = "RunnerCardHasScansError"

	@IsString()
	message = "This card still has scans associated with it. \n If you want to delete this card with all it's scans add `?force` to your query. \n Otherwise please consider just disabling it."
}

/**
 * Error to throw when a card's id is too big to generate a ean-13 barcode for it.
 * This error should never reach a end user.
 */
export class RunnerCardIdOutOfRangeError extends Error {
	@IsString()
	name = "RunnerCardIdOutOfRangeError"

	@IsString()
	message = "The card's id is too big to fit into a ean-13 barcode. \n This has a very low probability of happening but means that you might want to switch your barcode format for something that can accept numbers over 9999999999."
}