(result: Expression)
| 1192 | |
| 1193 | //@note: '.subs()' acts like an expr. 'clone' here (in case of an empty substitution) |
| 1194 | // An exception thrown by a `replace` *function* is treated exactly like a |
| 1195 | // condition exception handled by `matchRule`: log it and skip this rule |
| 1196 | // rather than aborting the `replace()` pass. Deadline cancellations still |
| 1197 | // propagate. |
| 1198 | let result: Expression | RuleStep | null | undefined; |
| 1199 | try { |
| 1200 | result = |
| 1201 | typeof replace === 'function' |
| 1202 | ? replace(expr, sub) |
| 1203 | : // @todo: 'expr.subs()' to eventually also assume a 'form' option |
| 1204 | // : replace.subs(sub, { form: dynamicForm ? undefined : formValue }); |
| 1205 | replace.subs(sub, { canonical: getFormType() === 'canonical' }); |
| 1206 | } catch (e) { |
| 1207 | if (e instanceof CancellationError) throw e; |
| 1208 | console.error( |
| 1209 | `\n| Rule "${rule.id}"\n| Error while applying replacement\n| ${ |
| 1210 | e instanceof Error ? e.message : e |
no test coverage detected