diff --git a/src/Controller/WorkshopsController.php b/src/Controller/WorkshopsController.php index 74b5728d1..34cf16dea 100644 --- a/src/Controller/WorkshopsController.php +++ b/src/Controller/WorkshopsController.php @@ -405,7 +405,7 @@ public function getWorkshopsWithCityFilter() { $city = $this->request->getQuery('city'); if ($city === null || strlen($city) < 3) { - throw new NotFoundException('city not passed or invalid (min 3 chars)'); + return $this->response->withStatus(400)->withType('json')->withStringBody(json_encode('city not passed or invalid (min 3 chars)')); } $workshops = $this->Workshop->find('all', @@ -422,6 +422,10 @@ public function getWorkshopsWithCityFilter() { ], order: ['Workshops.name' => 'asc']); + if ($workshops->count() == 0) { + return $this->response->withStatus(404)->withType('json')->withStringBody(json_encode('no workshops found')); + } + $preparedWorkshops = []; foreach($workshops as $workshop) {