@@ -61,7 +61,6 @@ sub parseRequest {
61
61
# override key-values in params with those provided in the JWT
62
62
@params { keys %$claims } = values %$claims ;
63
63
}
64
- warn join (' , ' , keys %params );
65
64
return \%params ;
66
65
}
67
66
@@ -118,41 +117,25 @@ async sub problem {
118
117
}
119
118
120
119
my $problem = $c -> newProblem({ log => $c -> log , read_path => $file_path , random_seed => $random_seed , problem_contents => $problem_contents });
121
- return $c -> exception($problem -> {_message }, status => $problem -> {status }) unless $problem -> success();
120
+ return $c -> exception($problem -> {_message }, $problem -> {status })
121
+ unless $problem -> success();
122
122
123
123
$inputs_ref -> {sourceFilePath } = $problem -> {read_path }; # in case the path was updated...
124
124
125
- my @input_errs = checkInputs($inputs_ref );
126
- if (@input_errs ) {
127
- my $err_log = " Form data submitted for " .$inputs_ref -> {sourceFilePath }." contained errors: {" ;
128
- $err_log .= join " }, {" , @input_errs ;
129
- $c -> log -> error($err_log ." }" );
130
- }
125
+ my $input_errs = checkInputs($inputs_ref );
131
126
132
- $c -> render_later;
127
+ $c -> render_later; # tell Mojo that this might take a while
133
128
my $ww_return_json = await $problem -> render($inputs_ref );
134
129
135
- unless ($problem -> success()) {
136
- $c -> log -> warn ($problem -> {_message });
137
- return $c -> render(
138
- json => $problem -> errport(),
139
- status => $problem -> {status }
140
- );
141
- }
130
+ return $c -> exception( $problem -> {_message }, $problem -> {status } )
131
+ unless $problem -> success();
142
132
143
133
my $ww_return_hash = decode_json($ww_return_json );
144
- my @output_errs = checkOutputs($ww_return_hash );
145
- if (@output_errs ) {
146
- my $err_log = " Output from rendering " .$inputs_ref -> {sourceFilePath }." contained errors: {" ;
147
- $err_log .= join " }, {" , @output_errs ;
148
- $c -> log -> error($err_log ." }" );
149
- }
134
+ my $output_errs = checkOutputs($ww_return_hash );
150
135
151
- $ww_return_hash -> {debug }-> {render_warn } = [@ input_errs , @ output_errs ];
136
+ $ww_return_hash -> {debug }-> {render_warn } = [$ input_errs , $ output_errs ];
152
137
153
138
# if answers are submitted and there is a provided answerURL...
154
-
155
-
156
139
if ($inputs_ref -> {JWTanswerURL } && $ww_return_hash -> {answerJWT } && $inputs_ref -> {submitAnswers }) {
157
140
my $answerJWTresponse = {
158
141
iss => $ENV {SITE_HOST },
@@ -220,7 +203,11 @@ sub checkInputs {
220
203
push @errs , $err ;
221
204
}
222
205
}
223
- return @errs ;
206
+ return " Form data submitted for "
207
+ . $inputs_ref -> {sourceFilePath }
208
+ . " contained errors: {"
209
+ . join " }, {" , @errs
210
+ . " }" ;
224
211
}
225
212
226
213
sub checkOutputs {
@@ -248,14 +235,19 @@ sub checkOutputs {
248
235
}
249
236
}
250
237
}
251
- return @errs ;
238
+ return
239
+ " Output from rendering "
240
+ . $outputs_ref -> {sourceFilePath }
241
+ . " contained errors: {"
242
+ . join " }, {" , @errs . " }" ;
252
243
}
253
244
254
245
sub exception {
255
246
my $c = shift ;
256
247
my $id = $c -> logID;
257
248
my $message = " [$id ] " . shift ;
258
249
my $status = shift ;
250
+ $c -> log -> error(" ($status ) EXCEPTION: $message " );
259
251
return $c -> respond_to(
260
252
json => { json => {
261
253
message => $message ,
0 commit comments