* @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows this continuation. * @param continuationArgName The argument name for the continuation that follows this call.
(node, onRejected, transformer, hasContinuation, continuationArgName)
| 151718 | * @param continuationArgName The argument name for the continuation that follows this call. |
| 151719 | */ |
| 151720 | function transformCatch(node, onRejected, transformer, hasContinuation, continuationArgName) { |
| 151721 | if (!onRejected || isNullOrUndefined(transformer, onRejected)) { |
| 151722 | // Ignore this call as it has no effect on the result |
| 151723 | return transformExpression(/* returnContextNode */ node, node.expression.expression, transformer, hasContinuation, continuationArgName); |
| 151724 | } |
| 151725 | var inputArgName = getArgBindingName(onRejected, transformer); |
| 151726 | var possibleNameForVarDecl = getPossibleNameForVarDecl(node, transformer, continuationArgName); |
| 151727 | // Transform the left-hand-side of `.then`/`.catch` into an array of inlined statements. We pass `true` for hasContinuation as `node` is the outer continuation. |
| 151728 | var inlinedLeftHandSide = transformExpression(/*returnContextNode*/ node, node.expression.expression, transformer, /*hasContinuation*/ true, possibleNameForVarDecl); |
| 151729 | if (hasFailed()) |
| 151730 | return silentFail(); // shortcut out of more work |
| 151731 | // Transform the callback argument into an array of inlined statements. We pass whether we have an outer continuation here |
| 151732 | // as that indicates whether `return` is valid. |
| 151733 | var inlinedCallback = transformCallbackArgument(onRejected, hasContinuation, possibleNameForVarDecl, inputArgName, node, transformer); |
| 151734 | if (hasFailed()) |
| 151735 | return silentFail(); // shortcut out of more work |
| 151736 | var tryBlock = ts.factory.createBlock(inlinedLeftHandSide); |
| 151737 | var catchClause = ts.factory.createCatchClause(inputArgName && ts.getSynthesizedDeepClone(declareSynthBindingName(inputArgName)), ts.factory.createBlock(inlinedCallback)); |
| 151738 | var tryStatement = ts.factory.createTryStatement(tryBlock, catchClause, /*finallyBlock*/ undefined); |
| 151739 | return finishCatchOrFinallyTransform(node, transformer, tryStatement, possibleNameForVarDecl, continuationArgName); |
| 151740 | } |
| 151741 | /** |
| 151742 | * @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows this continuation. |
| 151743 | * @param continuationArgName The argument name for the continuation that follows this call. |
no test coverage detected