From f0eb0199ec8de0e76c7b75ddc80275cde8f12818 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 6 Sep 2021 16:42:51 +0200 Subject: Throw instead of log error from Concert class. Should get rid of most of the annoying output during testing, and allow moving error handling and logging to the presentation layer. --- includes/concert.php | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'includes/concert.php') diff --git a/includes/concert.php b/includes/concert.php index f0a9ecd..089e9a7 100644 --- a/includes/concert.php +++ b/includes/concert.php @@ -7,6 +7,13 @@ require_once __DIR__ . '/venue.php'; +if ( !class_exists('GiglogAdmin_DuplicateConcertException') ) +{ + class GiglogAdmin_DuplicateConcertException extends Exception + { + } +} + if ( !class_exists('GiglogAdmin_Concert') ) { require_once __DIR__ . '/venue.php'; @@ -105,12 +112,8 @@ if ( !class_exists('GiglogAdmin_Concert') ) { ]); if (!empty($gigs)) { - error_log( 'DUPLICATE ROW detected: ' - . ' CONCERT NAME ' . $name - . ', VENUE ID ' . $venue_id - . ', CONCERTDATE ' . $date); - - return NULL; + throw new GiglogAdmin_DuplicateConcertException( + "Duplicate concert: name: {$name}, venue_id: {$venue_id}, date: {$date}"); } else { $concert = new GiglogAdmin_Concert( (object) [ @@ -123,14 +126,6 @@ if ( !class_exists('GiglogAdmin_Concert') ) { $concert->save(); - error_log( 'NEW CONCERT ADDED: ' - . ' ID: ' . $concert -> id() - . ' CONCERT NAME ' . $name - . ', VENUE ID ' . $venue_id - . ', CONCERTDATE ' . $date - . ', Ticket LINK ' . $ticketlink - . ', Event LINK ' . $eventlink); - return $concert; } } -- cgit v1.2.3