Raise a BookNotFoundException when the book is not found
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once('DbMapping.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)
|
function convertMSChar($src)
|
||||||
{
|
{
|
||||||
@@ -166,7 +171,7 @@ class AudioBook extends DbMapping
|
|||||||
/**
|
/**
|
||||||
* @param $code
|
* @param $code
|
||||||
* @return int
|
* @return int
|
||||||
* @throws Exception
|
* @throws BookNotFoundException
|
||||||
* @throws SqlException
|
* @throws SqlException
|
||||||
*/
|
*/
|
||||||
public static function findIdByCode($code)
|
public static function findIdByCode($code)
|
||||||
@@ -174,7 +179,7 @@ class AudioBook extends DbMapping
|
|||||||
$sql = "SELECT NoticeId FROM Notices WHERE LTRIM(RTRIM(NoticeNr)) = '$code';";
|
$sql = "SELECT NoticeId FROM Notices WHERE LTRIM(RTRIM(NoticeNr)) = '$code';";
|
||||||
$result = Connection::execute($sql, false);
|
$result = Connection::execute($sql, false);
|
||||||
if ($result === false || $result->length == 0) {
|
if ($result === false || $result->length == 0) {
|
||||||
throw new Exception("NotFoundException");
|
throw new BookNotFoundException($code);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = $result->current();
|
$row = $result->current();
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require_once "global.php";
|
require_once "global.php";
|
||||||
|
require_once "mobile.webservice.php";
|
||||||
|
|
||||||
require_once "lib/AudioBook.php";
|
require_once "lib/AudioBook.php";
|
||||||
require_once "lib/User.php";
|
require_once "lib/User.php";
|
||||||
require_once "lib/BookSearch.php";
|
require_once "lib/BookSearch.php";
|
||||||
|
|
||||||
require_once "mobile.webservice.php";
|
|
||||||
|
|
||||||
class NetBiblio extends WebService
|
class NetBiblio extends WebService
|
||||||
{
|
{
|
||||||
private $data = array();
|
private $data = array();
|
||||||
|
|||||||
Reference in New Issue
Block a user