backend/src/errors/TrackErrors.ts

27 lines
924 B
TypeScript
Raw Normal View History

2020-11-27 20:35:28 +00:00
import { JsonController, Param, Body, Get, Post, Put, Delete, NotFoundError, OnUndefined, NotAcceptableError } from 'routing-controllers';
import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator';
/**
* Error to throw when a track couldn't be found.
* Implemented this ways to work with the json-schema conversion for openapi.
*/
2020-11-27 20:35:28 +00:00
export class TrackNotFoundError extends NotFoundError {
@IsString()
name = "TrackNotFoundError"
@IsString()
message = "Track not found!"
}
/**
* Error to throw when two tracks' ids don't match.
* Usually occurs when a user tries to change a track's id.
* Implemented this ways to work with the json-schema conversion for openapi.
*/
export class TrackIdsNotMatchingError extends NotAcceptableError {
2020-11-27 20:35:28 +00:00
@IsString()
name = "TrackIdsNotMatchingError"
2020-11-27 20:35:28 +00:00
@IsString()
2020-11-27 20:40:00 +00:00
message = "The id's don't match!! \n And if you wanted to change a track's id: This isn't allowed"
2020-11-27 20:35:28 +00:00
}