diff --git a/src/controllers/RunnerController.ts b/src/controllers/RunnerController.ts index acee2eb..9d7a847 100644 --- a/src/controllers/RunnerController.ts +++ b/src/controllers/RunnerController.ts @@ -39,7 +39,9 @@ export class RunnerController { @OnUndefined(RunnerNotFoundError) @OpenAPI({ description: 'Returns a runner of a specified id (if it exists)' }) async getOne(@Param('id') id: number) { - return new ResponseRunner(await this.runnerRepository.findOne({ id: id }, { relations: ['scans', 'group'] })); + let runner = await this.runnerRepository.findOne({ id: id }, { relations: ['scans', 'group'] }) + if (!runner) { throw new RunnerNotFoundError(); } + return new ResponseRunner(runner); } @Post() diff --git a/src/controllers/RunnerOrganisationController.ts b/src/controllers/RunnerOrganisationController.ts index 3ad839e..5636fa6 100644 --- a/src/controllers/RunnerOrganisationController.ts +++ b/src/controllers/RunnerOrganisationController.ts @@ -41,7 +41,9 @@ export class RunnerOrganisationController { @OnUndefined(RunnerOrganisationNotFoundError) @OpenAPI({ description: 'Returns a runnerOrganisation of a specified id (if it exists)' }) async getOne(@Param('id') id: number) { - return new ResponseRunnerOrganisation(await this.runnerOrganisationRepository.findOne({ id: id }, { relations: ['address', 'contact', 'teams'] })); + let runnerOrg = await this.runnerOrganisationRepository.findOne({ id: id }, { relations: ['address', 'contact', 'teams'] }); + if (!runnerOrg) { throw new RunnerOrganisationNotFoundError(); } + return new ResponseRunnerOrganisation(runnerOrg); } @Post() diff --git a/src/controllers/RunnerTeamController.ts b/src/controllers/RunnerTeamController.ts index 7b0a841..148f16d 100644 --- a/src/controllers/RunnerTeamController.ts +++ b/src/controllers/RunnerTeamController.ts @@ -40,7 +40,9 @@ export class RunnerTeamController { @OnUndefined(RunnerTeamNotFoundError) @OpenAPI({ description: 'Returns a runnerTeam of a specified id (if it exists)' }) async getOne(@Param('id') id: number) { - return new ResponseRunnerTeam(await this.runnerTeamRepository.findOne({ id: id }, { relations: ['parentGroup', 'contact'] })); + let runnerTeam = await this.runnerTeamRepository.findOne({ id: id }, { relations: ['parentGroup', 'contact'] }); + if (!runnerTeam) { throw new RunnerTeamNotFoundError(); } + return new ResponseRunnerTeam(runnerTeam); } @Post() diff --git a/src/controllers/TrackController.ts b/src/controllers/TrackController.ts index 149b837..bf5fb71 100644 --- a/src/controllers/TrackController.ts +++ b/src/controllers/TrackController.ts @@ -37,7 +37,9 @@ export class TrackController { @OnUndefined(TrackNotFoundError) @OpenAPI({ description: "Returns a track of a specified id (if it exists)" }) async getOne(@Param('id') id: number) { - return new ResponseTrack(await this.trackRepository.findOne({ id: id })); + let track = await this.trackRepository.findOne({ id: id }); + if (!track) { throw new TrackNotFoundError(); } + return new ResponseTrack(track); } @Post()