move all exception declaration to their own file
This commit is contained in:
49
exceptions.php
Normal file
49
exceptions.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class WebException extends Exception
|
||||||
|
{
|
||||||
|
private $excname;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param string $reason
|
||||||
|
* @param int $code
|
||||||
|
*/
|
||||||
|
function __construct($name, $reason, $code)
|
||||||
|
{
|
||||||
|
$this->excname = $name;
|
||||||
|
parent::__construct($reason, $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->excname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SqlException extends Exception
|
||||||
|
{
|
||||||
|
private $query;
|
||||||
|
|
||||||
|
public function __construct($message = "Sql Error", $query = "")
|
||||||
|
{
|
||||||
|
$this->query = $query;
|
||||||
|
parent::__construct($message, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSqlError()
|
||||||
|
{
|
||||||
|
return $this->getMessage().' while executing: '.$this->query;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BookNotFoundException extends WebException {
|
||||||
|
public function __construct($code) {
|
||||||
|
parent::__construct('BookNotFound', "The book with code $code was not found", -404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception raised when an invalid attribute name is accessed
|
||||||
|
*/
|
||||||
|
class InvalidAttributeException extends Exception { }
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once('exceptions.php');
|
||||||
require_once('configuration.php');
|
require_once('configuration.php');
|
||||||
require_once('lib/Connection.php');
|
require_once('lib/Connection.php');
|
||||||
|
|||||||
@@ -2,12 +2,6 @@
|
|||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AudioBook is mapped on a Notice from NetBiblio
|
* AudioBook is mapped on a Notice from NetBiblio
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -52,22 +52,6 @@ class Connection
|
|||||||
final private function __clone() {}
|
final private function __clone() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SqlException extends Exception
|
|
||||||
{
|
|
||||||
private $query;
|
|
||||||
|
|
||||||
public function __construct($message = "Sql Error", $query = "")
|
|
||||||
{
|
|
||||||
$this->query = $query;
|
|
||||||
parent::__construct($message, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSqlError()
|
|
||||||
{
|
|
||||||
return $this->getMessage().' while executing: '.$this->query;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class OdbcResultSet implements Iterator, ArrayAccess
|
class OdbcResultSet implements Iterator, ArrayAccess
|
||||||
{
|
{
|
||||||
public $length;
|
public $length;
|
||||||
|
|||||||
@@ -120,9 +120,3 @@ abstract class DbMapping
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exception raised when an invalid attribute name is accessed
|
|
||||||
*/
|
|
||||||
class InvalidAttributeException extends Exception { }
|
|
||||||
|
|||||||
@@ -1,26 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class WebException extends Exception
|
|
||||||
{
|
|
||||||
private $excname;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $name
|
|
||||||
* @param string $reason
|
|
||||||
* @param int $code
|
|
||||||
*/
|
|
||||||
function __construct($name, $reason, $code)
|
|
||||||
{
|
|
||||||
$this->excname = $name;
|
|
||||||
parent::__construct($reason, $code);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return $this->excname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class WebService
|
abstract class WebService
|
||||||
{
|
{
|
||||||
private $func = null;
|
private $func = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user