mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
Started to implement better exceptions
This commit is contained in:
parent
952cec0bf9
commit
ca03e96fb9
45
AutoloadException.php
Normal file
45
AutoloadException.php
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.0
|
||||||
|
*
|
||||||
|
* @category TBD
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @copyright 2013 Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
*/
|
||||||
|
namespace phpOMS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permission exception class.
|
||||||
|
*
|
||||||
|
* @category Framework
|
||||||
|
* @package phpOMS\System\File
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class AutoloadException extends \RuntimeException
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $message Exception message
|
||||||
|
* @param int $code Exception code
|
||||||
|
* @param \Exception Previous exception
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function __construct(string $message, int $code = 0, \Exception $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct('File "' . $message . '" could not get loaded.', $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ class Autoloader
|
||||||
/** @noinspection PhpIncludeInspection */
|
/** @noinspection PhpIncludeInspection */
|
||||||
include __DIR__ . '/../' . $classNew . '.php';
|
include __DIR__ . '/../' . $classNew . '.php';
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception($class);
|
throw new AutoloaderException($class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Cookie;
|
namespace phpOMS\DataStorage\Cookie;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\LockException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CookieJar class
|
* CookieJar class
|
||||||
*
|
*
|
||||||
|
|
@ -160,7 +162,7 @@ class CookieJar
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
if (self::$isLocked) {
|
if (self::$isLocked) {
|
||||||
throw new \Exception('Already locked');
|
throw new LockException('CookieJar');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->cookies as $key => $cookie) {
|
foreach ($this->cookies as $key => $cookie) {
|
||||||
|
|
|
||||||
45
DataStorage/LockException.php
Normal file
45
DataStorage/LockException.php
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.0
|
||||||
|
*
|
||||||
|
* @category TBD
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @copyright 2013 Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
*/
|
||||||
|
namespace phpOMS\DataStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permission exception class.
|
||||||
|
*
|
||||||
|
* @category Framework
|
||||||
|
* @package phpOMS\System\File
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class LockException extends \RuntimeException
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $message Exception message
|
||||||
|
* @param int $code Exception code
|
||||||
|
* @param \Exception Previous exception
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function __construct(string $message, int $code = 0, \Exception $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct('Interaction with "' . $message . '" already locked.', $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,6 +17,7 @@ namespace phpOMS\DataStorage\Session;
|
||||||
|
|
||||||
use phpOMS\Uri\UriFactory;
|
use phpOMS\Uri\UriFactory;
|
||||||
use phpOMS\Utils\RnG\StringUtils;
|
use phpOMS\Utils\RnG\StringUtils;
|
||||||
|
use phpOMS\DataStorage\LockException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Http session class.
|
* Http session class.
|
||||||
|
|
@ -62,7 +63,7 @@ class HttpSession implements SessionInterface
|
||||||
* @param int $liftetime Session life time
|
* @param int $liftetime Session life time
|
||||||
* @param string|int|bool $sid Session id
|
* @param string|int|bool $sid Session id
|
||||||
*
|
*
|
||||||
* @throws \Exception Throws this exception if the session is alrady locked for further interaction.
|
* @throws LockException Throws this exception if the session is alrady locked for further interaction.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
|
@ -70,7 +71,7 @@ class HttpSession implements SessionInterface
|
||||||
public function __construct(int $liftetime = 3600, $sid = false)
|
public function __construct(int $liftetime = 3600, $sid = false)
|
||||||
{
|
{
|
||||||
if (self::$isLocked) {
|
if (self::$isLocked) {
|
||||||
throw new \Exception('Already locked');
|
throw new LockException('HttpSession');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_bool($sid)) {
|
if (!is_bool($sid)) {
|
||||||
|
|
|
||||||
46
Math/Matrix/DimensionException.php
Normal file
46
Math/Matrix/DimensionException.php
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.0
|
||||||
|
*
|
||||||
|
* @category TBD
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @copyright 2013 Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
*/
|
||||||
|
namespace phpOMS\Math\Matrix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permission exception class.
|
||||||
|
*
|
||||||
|
* @category Framework
|
||||||
|
* @package phpOMS\System\File
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class DimensionException extends \RuntimeException
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param int $m Dimension M
|
||||||
|
* @param int $n Dimension N
|
||||||
|
* @param int $code Exception code
|
||||||
|
* @param \Exception Previous exception
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function __construct($m, $n, int $code = 0, \Exception $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct('Dimension of "' . $n . '-' . $m . '" invalid.', $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -95,7 +95,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
public function set(int $m, int $n, $value)
|
public function set(int $m, int $n, $value)
|
||||||
{
|
{
|
||||||
if (!isset($this->matrix[$m][$n])) {
|
if (!isset($this->matrix[$m][$n])) {
|
||||||
throw new \Exception('Dimension');
|
throw new DimensionException($m, $n);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->matrix[$m][$n] = $value;
|
$this->matrix[$m][$n] = $value;
|
||||||
|
|
@ -117,7 +117,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
public function get(int $m, int $n)
|
public function get(int $m, int $n)
|
||||||
{
|
{
|
||||||
if (!isset($this->matrix[$m][$n])) {
|
if (!isset($this->matrix[$m][$n])) {
|
||||||
throw new \Exception('Dimension');
|
throw new DimensionException($m, $n);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->matrix[$m][$n];
|
return $this->matrix[$m][$n];
|
||||||
|
|
@ -165,7 +165,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
public function setMatrix(array $matrix)
|
public function setMatrix(array $matrix)
|
||||||
{
|
{
|
||||||
if ($this->m !== count($matrix) || $this->n !== count($matrix[0])) {
|
if ($this->m !== count($matrix) || $this->n !== count($matrix[0])) {
|
||||||
throw new \Exception('Dimension');
|
throw new DimensionException(count($matrix), count($matrix[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->matrix = $matrix;
|
$this->matrix = $matrix;
|
||||||
|
|
@ -232,7 +232,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
private function addMatrix(Matrix $matrix) : Matrix
|
private function addMatrix(Matrix $matrix) : Matrix
|
||||||
{
|
{
|
||||||
if ($this->m !== $matrix->getM() || $this->n !== $matrix->getN()) {
|
if ($this->m !== $matrix->getM() || $this->n !== $matrix->getN()) {
|
||||||
throw new \Exception('Dimension');
|
throw new DimensionException($matrix->getM(), $matrix->getN());
|
||||||
}
|
}
|
||||||
|
|
||||||
$matrixArr = $matrix->getMatrix();
|
$matrixArr = $matrix->getMatrix();
|
||||||
|
|
@ -345,7 +345,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
$mDim = $matrix->getM();
|
$mDim = $matrix->getM();
|
||||||
|
|
||||||
if ($this->n !== $mDim) {
|
if ($this->n !== $mDim) {
|
||||||
throw new \Exception('Dimension');
|
throw new DimensionException($mDim, $nDim);
|
||||||
}
|
}
|
||||||
|
|
||||||
$matrixArr = $matrix->getMatrix();
|
$matrixArr = $matrix->getMatrix();
|
||||||
|
|
@ -496,7 +496,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
public function inverse(int $algorithm = InverseType::GAUSS_JORDAN) : Matrix
|
public function inverse(int $algorithm = InverseType::GAUSS_JORDAN) : Matrix
|
||||||
{
|
{
|
||||||
if ($this->n !== $this->m) {
|
if ($this->n !== $this->m) {
|
||||||
throw new \Exception('Dimension');
|
throw new DimensionException($this->m, $this->n);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($algorithm) {
|
switch ($algorithm) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user