Raise a BookNotFoundException when the book is not found
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
require_once('DbMapping.php');
|
||||
|
||||
class BookNotFoundException extends WebException {
|
||||
public function __construct($code) {
|
||||
parent::__construct('BookNotFound', "The book with code $code was not found", -404);
|
||||
}
|
||||
}
|
||||
|
||||
function convertMSChar($src)
|
||||
{
|
||||
@@ -166,7 +171,7 @@ class AudioBook extends DbMapping
|
||||
/**
|
||||
* @param $code
|
||||
* @return int
|
||||
* @throws Exception
|
||||
* @throws BookNotFoundException
|
||||
* @throws SqlException
|
||||
*/
|
||||
public static function findIdByCode($code)
|
||||
@@ -174,7 +179,7 @@ class AudioBook extends DbMapping
|
||||
$sql = "SELECT NoticeId FROM Notices WHERE LTRIM(RTRIM(NoticeNr)) = '$code';";
|
||||
$result = Connection::execute($sql, false);
|
||||
if ($result === false || $result->length == 0) {
|
||||
throw new Exception("NotFoundException");
|
||||
throw new BookNotFoundException($code);
|
||||
}
|
||||
|
||||
$row = $result->current();
|
||||
|
||||
Reference in New Issue
Block a user