@@ -1809,6 +1809,7 @@ public struct BridgeJSLink {
18091809 body . write ( " const \( returnVariable ) = \( call ) ; " )
18101810 fragmentArguments = [ returnVariable ]
18111811 }
1812+ body . write ( lines : checkExceptionLines ( ) )
18121813 let liftedValues = try liftingFragment . printCode ( fragmentArguments , context )
18131814 assert ( liftedValues . count <= 1 , " Lifting fragment should produce at most one value " )
18141815 return liftedValues . first
@@ -1818,10 +1819,11 @@ public struct BridgeJSLink {
18181819 let call =
18191820 " \( JSGlueVariableScope . reservedInstance ) .exports. \( abiName ) ( \( parameterForwardings . joined ( separator : " , " ) ) ) "
18201821 body . write ( " const ret = \( call ) ; " )
1822+ body . write ( lines : checkExceptionLines ( ) )
18211823 return " ret "
18221824 }
18231825
1824- func checkExceptionLines ( ) -> [ String ] {
1826+ private func checkExceptionLines ( ) -> [ String ] {
18251827 guard effects . isThrows else {
18261828 return [ ]
18271829 }
@@ -1837,10 +1839,9 @@ public struct BridgeJSLink {
18371839 ]
18381840 }
18391841
1840- /// Renders the thunk body (body code, exception handling, and optional return) into a printer .
1842+ /// Renders the thunk body and optional return; `call`/`callConstructor` put the exception check in `body` .
18411843 func renderFunctionBody ( into printer : CodeFragmentPrinter , returnExpr : String ? ) {
18421844 printer . write ( contentsOf : body )
1843- printer . write ( lines : checkExceptionLines ( ) )
18441845 if let returnExpr = returnExpr {
18451846 printer . write ( " return \( returnExpr ) ; " )
18461847 }
@@ -3490,7 +3491,6 @@ extension BridgeJSLink {
34903491 getterPrinter . write ( " get \( property . resolvedJSName ) () { " )
34913492 getterPrinter . indent {
34923493 getterPrinter . write ( contentsOf : getterThunkBuilder . body )
3493- getterPrinter . write ( lines : getterThunkBuilder . checkExceptionLines ( ) )
34943494 if let returnExpr = getterReturnExpr {
34953495 getterPrinter . write ( " return \( returnExpr ) ; " )
34963496 }
@@ -3517,7 +3517,6 @@ extension BridgeJSLink {
35173517 setterPrinter . write ( " set \( property . resolvedJSName ) ( \( setterThunkBuilder . parameterList ) ) { " )
35183518 setterPrinter . indent {
35193519 setterPrinter . write ( contentsOf : setterThunkBuilder . body )
3520- setterPrinter . write ( lines : setterThunkBuilder . checkExceptionLines ( ) )
35213520 }
35223521 setterPrinter . write ( " }, " )
35233522
0 commit comments