Improved error handling for negative lap times

ref #71
This commit is contained in:
2021-01-03 17:21:53 +01:00
parent dcb791c9a2
commit 28c1b6d31d
5 changed files with 24 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
import { IsInt, IsOptional, IsString } from "class-validator";
import { TrackLapTimeCantBeNegativeError } from '../../errors/TrackErrors';
import { Track } from '../entities/Track';
/**
@@ -40,5 +41,8 @@ export class ResponseTrack {
this.name = track.name;
this.distance = track.distance;
this.minimumLapTime = track.minimumLapTime;
if (this.minimumLapTime < 0) {
throw new TrackLapTimeCantBeNegativeError();
}
}
}