@hotmeshio/hotmesh
Version:
Permanent-Memory Workflows & AI Agents
44 lines (43 loc) • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.didInterrupt = void 0;
const errors_1 = require("../../../modules/errors");
/**
* Checks if an error is a HotMesh reserved error type that indicates
* a HotMesh interruption rather than a true error condition.
*
* When this returns true, you can safely return rethrow the error.
* The workflow engine will handle the interruption automatically.
*
* @example
* ```typescript
* import { MemFlow } from '@hotmeshio/hotmesh';
*
* try {
* await someWorkflowOperation();
* } catch (error) {
* // Check if this is a HotMesh interruption
* if (MemFlow.workflow.didInterrupt(error)) {
* // Rethrow the error
* throw error;
* }
* // Handle actual error
* console.error('Workflow failed:', error);
* }
* ```
*
* @param error - The error to check
* @returns true if the error is a HotMesh interruption
*/
function didInterrupt(error) {
return (error instanceof errors_1.MemFlowChildError ||
error instanceof errors_1.MemFlowFatalError ||
error instanceof errors_1.MemFlowMaxedError ||
error instanceof errors_1.MemFlowProxyError ||
error instanceof errors_1.MemFlowRetryError ||
error instanceof errors_1.MemFlowSleepError ||
error instanceof errors_1.MemFlowTimeoutError ||
error instanceof errors_1.MemFlowWaitForError ||
error instanceof errors_1.MemFlowWaitForAllError);
}
exports.didInterrupt = didInterrupt;