Merge pull request #333 from SyncrowIOT/SP-1430-be-api-request-returns-400-bad-request-instead-of-empty-array-when-community-has-no-devices-or-spaces

refactor: improve error handling for missing space in device listing
This commit is contained in:
faljawhary
2025-04-14 14:26:37 +03:00
committed by GitHub

View File

@ -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 =