33using JasperFx . CodeGeneration . Model ;
44using JasperFx . Core . Reflection ;
55using Microsoft . AspNetCore . Http ;
6+ using Wolverine . Configuration ;
67
78namespace Wolverine . Http . CodeGen ;
89
@@ -133,7 +134,7 @@ private void writeStringValueFSharp(GeneratedMethod method, ISourceWriter writer
133134 // A missing required route value 404s and aborts. F# has no early return, so the rest of
134135 // the chain renders inside the else branch.
135136 writer . Write ( $ "BLOCK:if isNull { Variable . Usage } then") ;
136- writeStatusAbort ( writer ) ;
137+ writeStatusAbort ( method , writer ) ;
137138 writer . FinishBlock ( ) ;
138139 writer . Write ( "BLOCK:else" ) ;
139140 WriteNextOrUnit ( method , writer ) ;
@@ -167,15 +168,15 @@ private void writeParsedValueFSharp(GeneratedMethod method, ISourceWriter writer
167168 // Required route value: null or parse-failure 404s + aborts; success binds the variable and
168169 // renders the rest of the chain in the success match arm (no F# early return).
169170 writer . Write ( $ "BLOCK:if isNull { raw } then") ;
170- writeStatusAbort ( writer ) ;
171+ writeStatusAbort ( method , writer ) ;
171172 writer . FinishBlock ( ) ;
172173 writer . Write ( "BLOCK:else" ) ;
173174 writer . Write ( $ "BLOCK:match { fsharpTryParse ( raw ) } with") ;
174175 writer . Write ( $ "BLOCK:| true, { Variable . Usage } ->") ;
175176 WriteNextOrUnit ( method , writer ) ;
176177 writer . FinishBlock ( ) ;
177178 writer . Write ( "BLOCK:| _ ->" ) ;
178- writeStatusAbort ( writer ) ;
179+ writeStatusAbort ( method , writer ) ;
179180 writer . FinishBlock ( ) ;
180181 writer . FinishBlock ( ) ; // match
181182 writer . FinishBlock ( ) ; // else
@@ -197,14 +198,14 @@ private void WriteNextOrUnit(GeneratedMethod method, ISourceWriter writer)
197198 }
198199 else
199200 {
200- writer . Write ( "()" ) ;
201+ writer . Write ( FSharpEmitHelpers . AbortExpression ( method ) ) ;
201202 }
202203 }
203204
204- private static void writeStatusAbort ( ISourceWriter writer )
205+ private static void writeStatusAbort ( GeneratedMethod method , ISourceWriter writer )
205206 {
206207 writer . Write ( $ "httpContext.Response.{ nameof ( HttpResponse . StatusCode ) } <- 404") ;
207- writer . Write ( "()" ) ;
208+ writer . Write ( FSharpEmitHelpers . AbortExpression ( method ) ) ;
208209 }
209210
210211 // The F# tuple form of the C# out-parameter TryParse (F# auto-tuples the out arg).
0 commit comments