@@ -256,15 +256,18 @@ get '/match/:id' => sub {
256
256
my $userid = user()-> {username };
257
257
258
258
my $matchid = param(' id' );
259
- my $match = get_match($matchid ) or do {
260
- flash error => no_match => $matchid ;
261
- return redirect request.uri_for(' /' );
262
- };
263
-
264
- my $game = get_game($match -> {game }) or do {
265
- flash error => no_game => $match -> {game };
266
- return redirect request.uri_for(' /' );
259
+ my ($match , $game );
260
+ try {
261
+ $match = get_match($matchid ) or do {
262
+ flash error => no_match => $matchid ;
263
+ die {};
264
+ };
265
+ $game = get_game($match -> {game }) or do {
266
+ flash error => no_game => $match -> {game };
267
+ die {};
268
+ };
267
269
};
270
+ return redirect request()-> uri_for(' /' ) unless defined $game ;
268
271
269
272
my $gameid = $game -> {id };
270
273
my $template = " games/$gameid " ;
@@ -304,7 +307,7 @@ post '/match' => sub {
304
307
catch {
305
308
warning " caught error during forward: $_ " ;
306
309
};
307
- return redirect request . uri_for(' /' );
310
+ return redirect request() -> uri_for(' /' );
308
311
};
309
312
310
313
post ' /match/joins/:id' => sub {
@@ -323,7 +326,7 @@ post '/match/joins/:id' => sub {
323
326
else {
324
327
flash warning => ' join_pending' ;
325
328
}
326
- return redirect ' /' ;
329
+ return redirect request() -> uri_for( ' /' ) ;
327
330
};
328
331
329
332
post ' /move' => sub {
@@ -357,7 +360,7 @@ post '/move' => sub {
357
360
};
358
361
359
362
# flash info => debug => to_json($move);
360
- return redirect " /match/$matchid " ;
363
+ return redirect request() -> uri_for( " /match/$matchid " ) ;
361
364
};
362
365
363
366
get ' /game/:id' => sub {
0 commit comments