Skip to main content

Checking System Pause Status

The isPaused method checks if the system is currently paused, which may prevent certain operations from being executed. This method interacts with the backend to retrieve the system's pause status.

Usage

import kohin from "./kohinInstance";

const isPausedResponse = await kohin.isPaused();

if (isPausedResponse.success) {
console.log("System Paused:", isPausedResponse.isPause);
toastify(
isPausedResponse.isPause ? "System is paused." : "System is active.",
"autoInfo"
);
} else {
console.error("Error checking system pause status:", isPausedResponse.error);
toastify(`Error: ${isPausedResponse.error}`, "autoError");
}

Return Value

The isPaused method returns an object with the following structure:

{
success: boolean; // Indicates if the operation was successful
error?: string; // Error message if the operation failed
isPause?: boolean; // Indicates if the system is paused (true if paused, false if active)
}

Error Handling

The following example demonstrates how to handle errors while checking the system's pause status:

try {
const isPausedResponse = await kohin.isPaused();

if (isPausedResponse.success) {
if (isPausedResponse.isPause) {
toastify("System is paused.", "autoInfo");
} else {
toastify("System is active.", "autoSuccess");
}
} else {
toastify(`Error: ${isPausedResponse.error}`, "autoError");
console.error(
"Error checking system pause status:",
isPausedResponse.error
);
}
} catch (error: any) {
toastify(
"Unexpected error checking system pause status. Please try again.",
"autoError"
);
console.error("Unexpected error:", error);
}

Example Response

Success Response:

{
"success": true,
"isPause": true
}

Error Response:

{
"success": false,
"error": "Failed to retrieve system status."
}