From 777105fc28893504c9a06fda746bda30ed242e61 Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Mon, 14 Apr 2025 13:24:40 +0300 Subject: [PATCH] refactor: improve error handling for missing space in device listing --- src/space/services/space-device.service.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/space/services/space-device.service.ts b/src/space/services/space-device.service.ts index 773c7d5..df9597b 100644 --- a/src/space/services/space-device.service.ts +++ b/src/space/services/space-device.service.ts @@ -25,11 +25,8 @@ export class SpaceDeviceService { // Validate community, project, and fetch space including devices in a single query const space = await this.validationService.fetchSpaceDevices(spaceUuid); - if (!space || !space.devices?.length) { - throw new HttpException( - 'The space does not contain any devices.', - HttpStatus.BAD_REQUEST, - ); + if (!space) { + throw new HttpException('Space not found', HttpStatus.NOT_FOUND); } const spaceHierarchy =