UNPKG

@temporalio/testing

Version:
48 lines 1.81 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.interceptors = interceptors; const assert_1 = __importDefault(require("assert")); const workflow_1 = require("@temporalio/workflow"); /** * Simple interceptor that transforms {@link assert.AssertionError} into non retryable failures. * * This allows conveniently using `assert` directly from Workflows. */ function interceptors() { return { inbound: [ { async handleSignal(input, next) { try { return await next(input); } catch (err) { if (err instanceof assert_1.default.AssertionError) { const appErr = workflow_1.ApplicationFailure.nonRetryable(err.message); appErr.stack = err.stack; throw appErr; } throw err; } }, async execute(input, next) { try { return await next(input); } catch (err) { if (err instanceof assert_1.default.AssertionError) { const appErr = workflow_1.ApplicationFailure.nonRetryable(err.message); appErr.stack = err.stack; throw appErr; } throw err; } }, }, ], }; } //# sourceMappingURL=assert-to-failure-interceptor.js.map