diff --git a/src/tcl/tclStopPoint.controller.ts b/src/tcl/tclStopPoint.controller.ts index e49137f1e18d16a53674ea3610115ed7b1002ccf..d35876c75b7858a246bb7910d10d85c6b85e2357 100644 --- a/src/tcl/tclStopPoint.controller.ts +++ b/src/tcl/tclStopPoint.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Logger, Post, UseGuards } from '@nestjs/common'; +import { Body, Controller, HttpException, HttpStatus, Logger, Post, UseGuards } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { Roles } from '../users/decorators/roles.decorator'; @@ -37,6 +37,12 @@ export class TclStopPointController { }) @Post('/closest') public getClosestStopPoints(@Body() pgisCoord: PgisCoord): Promise<TclStopPoint[]> { + if (pgisCoord.coordinates.includes(null)) { + throw new HttpException( + `Invalid empty coordinate: ${JSON.stringify(pgisCoord.coordinates)}`, + HttpStatus.BAD_REQUEST + ); + } return this.tclStopPointService.getClosestStopPoints(pgisCoord); } }