From cb28dbaaba03b81b23b584f41e0f6a458b85db19 Mon Sep 17 00:00:00 2001 From: William Date: Sat, 19 Mar 2022 22:48:04 +0100 Subject: [PATCH] Commit --- public/race/simulator.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/public/race/simulator.php b/public/race/simulator.php index 301d217..3b409ad 100644 --- a/public/race/simulator.php +++ b/public/race/simulator.php @@ -1,7 +1,5 @@ model('Cardreader'); if ($_SERVER['REQUEST_METHOD'] === 'POST') @@ -10,8 +8,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $cardnumber = $_POST['cardnumber']; - if (!(strlen($cardnumber) > 32)) { - + try { $code = $cardreader->receive($cardnumber, 5); switch ($code) { case 0: @@ -21,7 +18,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') case 1: $app->session->flash('Startet telling', 'info'); break; - + case 2: $app->session->flash('Runde gikk for fort!', 'danger'); break; @@ -38,11 +35,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') $app->session->flash('Uhhh?? Dette skulle ikke skje', 'danger'); break; } - - } else { - $app->session->flash('Kortnummer for langt!', 'danger'); + } catch (InvalidArgumentException $e) { + $app->session->flash("Noe gikk galt: {$e->getMessage()}", "danger"); } - } else { + } else { $app->session->flash('Kortnummer kan ikke være tom!', 'danger'); } }