diff --git a/packages/rule-engine/package.json b/packages/rule-engine/package.json index c85f59d..1b92afb 100644 --- a/packages/rule-engine/package.json +++ b/packages/rule-engine/package.json @@ -1,6 +1,6 @@ { "name": "@freshworks-jaya/rule-engine", - "version": "0.18.6-beta-31", + "version": "0.18.7", "description": "Provides methods to process rules in product events in marketplace app", "repository": "git@github.com:freshdesk/jaya-lib.git", "main": "lib/index.js", diff --git a/packages/rule-engine/src/RuleProcessor.ts b/packages/rule-engine/src/RuleProcessor.ts index 3d76647..c3d535c 100644 --- a/packages/rule-engine/src/RuleProcessor.ts +++ b/packages/rule-engine/src/RuleProcessor.ts @@ -229,7 +229,7 @@ export class RuleProcessor { rules: Rule[], integrations: Integrations, options: RuleEngineOptions, - ): Promise { + ): Promise { for (const rule of rules) { if (this.isEnabledNonTimerRule(rule)) { try { @@ -240,6 +240,6 @@ export class RuleProcessor { } } } - throw new Error('no matching rule'); + return null; } } \ No newline at end of file diff --git a/packages/rule-engine/src/index.ts b/packages/rule-engine/src/index.ts index 430ea56..4869cb0 100644 --- a/packages/rule-engine/src/index.ts +++ b/packages/rule-engine/src/index.ts @@ -56,12 +56,12 @@ export class RuleEngine { // Process regular rules and get the actions of the first matching rule. try { const firstMatchingRule = await RuleProcessor.getFirstMatchingRule(payload.event, payload.data, rules, integrations, options); - if (firstMatchingRule.actions?.length) { + if (firstMatchingRule?.actions?.length) { const ruleAlias = firstMatchingRule.ruleAlias || ''; await ActionExecutor.handleActions(integrations, firstMatchingRule.actions, payload, apis, customPlaceholders, options, ruleAlias); } } catch (err) { - if (options.enableLogger || err !== 'no matching rule') { + if (options.enableLogger) { Utils.log(payload, integrations, ErrorCodes.FreshchatAction, { error: err as AnyJson}, LogSeverity.ALERT); } throw err; // Rethrow the error to be handled by the caller.