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'); } }