Raise a BookNotFoundException when the book is not found

master
Gilles Crettenand 11 years ago
parent c26e624480
commit a7705060a0

@ -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();

@ -7,12 +7,12 @@
*/
require_once "global.php";
require_once "mobile.webservice.php";
require_once "lib/AudioBook.php";
require_once "lib/User.php";
require_once "lib/BookSearch.php";
require_once "mobile.webservice.php";
class NetBiblio extends WebService
{
private $data = array();

Loading…
Cancel
Save