infra error handling
This commit is contained in:
1 parent
2e523cc431
commit
4e3630465c
1 file changed
+5
@@ -9,6 +9,7 @@ import type {
|
|||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
import ApiError from "@/utils/ApiError.js";
|
import ApiError from "@/utils/ApiError.js";
|
||||||
import { getChildLogger } from "@/logger/Logger.js";
|
import { getChildLogger } from "@/logger/Logger.js";
|
||||||
|
import { stat } from "node:fs";
|
||||||
|
|
||||||
const SERVICE_NAME = "CheckService";
|
const SERVICE_NAME = "CheckService";
|
||||||
const logger = getChildLogger(SERVICE_NAME);
|
const logger = getChildLogger(SERVICE_NAME);
|
||||||
@@ -134,6 +135,10 @@ class CheckService implements ICheckService {
|
|||||||
private buildInfrastructureCheck = (
|
private buildInfrastructureCheck = (
|
||||||
statusResponse: StatusResponse<ICapturePayload>
|
statusResponse: StatusResponse<ICapturePayload>
|
||||||
) => {
|
) => {
|
||||||
|
const code = statusResponse?.code;
|
||||||
|
if (code && (code < 200 || code >= 300)) {
|
||||||
|
throw new Error(statusResponse?.message || "Bad monitor response");
|
||||||
|
}
|
||||||
if (!this.isCapturePayload(statusResponse.payload)) {
|
if (!this.isCapturePayload(statusResponse.payload)) {
|
||||||
throw new Error("Invalid payload for infrastructure monitor");
|
throw new Error("Invalid payload for infrastructure monitor");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user