Skip to content

Commit

Permalink
fix: handle not found hashId in UI server
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
Jérôme Benoit committed Nov 30, 2023
1 parent 73edcc9 commit f12cf7e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/charging-station/ui-server/ui-services/AbstractUIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,21 @@ export abstract class AbstractUIService {
): void {
if (isNotEmptyArray(payload.hashIds)) {
payload.hashIds = payload.hashIds
?.filter((hashId) => !isNullOrUndefined(hashId))
?.map((hashId) => {
if (this.uiServer.chargingStations.has(hashId) === true) {
return hashId;
}
logger.warn(
`${this.logPrefix(
moduleName,
'sendBroadcastChannelRequest',
)} Charging station with hashId '${hashId}' not found`,
);
}) as string[];
const msg = `${this.logPrefix(
moduleName,
'sendBroadcastChannelRequest',
)} Charging station with hashId '${hashId}' not found`;
if (payload.hashIds?.length === 1) {
throw new BaseError(msg);
} else {
logger.warn(msg);
}
})
?.filter((hashId) => !isNullOrUndefined(hashId)) as string[];
}
const expectedNumberOfResponses = isNotEmptyArray(payload.hashIds)
? payload.hashIds!.length
Expand Down

0 comments on commit f12cf7e

Please sign in to comment.