Skip to content

Commit

Permalink
checking for null or whitespace instead of only null. (#270)
Browse files Browse the repository at this point in the history
Co-authored-by: August Andersen <[email protected]>
  • Loading branch information
augusthjerrild and August Andersen authored Oct 1, 2024
1 parent a527810 commit 977133b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/services/data-targets/data-target-log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DatatargetLog } from "@entities/datatarget-log.entity";
import { IoTDevice } from "@entities/iot-device.entity";
import { PayloadDecoder } from "@entities/payload-decoder.entity";
import { SendStatus } from "@enum/send-status.enum";
import { isNullOrWhitespace } from "@helpers/string.helper";
import { DataTargetSendStatus } from "@interfaces/data-target-send-status.interface";
import { HttpStatus, Injectable } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
Expand Down Expand Up @@ -36,11 +37,20 @@ export class DataTargetLogService {
if (datatargetLastestEvent?.type !== SendStatus.ERROR) return;
}

let statusText: string | null;
if (!isNullOrWhitespace(status?.statusText)) {
statusText = status?.statusText;
} else if (status?.statusCode) {
statusText = HttpStatus[status?.statusCode];
} else {
statusText = status?.errorMessage;
}

await this.handleDataTargetLogCommon(
datatarget,
status?.status,
status?.statusCode,
status?.statusText ?? (status?.statusCode ? HttpStatus[status?.statusCode] : status.errorMessage),
statusText,
payloadDto?.iotDeviceId,
payloadDto?.payloadDecoderId
);
Expand Down

0 comments on commit 977133b

Please sign in to comment.