mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
fixes #35
This commit is contained in:
parent
0c157cddf6
commit
c2e5dd8105
|
|
@ -113,7 +113,10 @@ abstract class SettingsAbstract implements OptionsInterface
|
|||
return $options;
|
||||
} catch (\PDOException $e) {
|
||||
// todo does it mean that the recognition isn't here but at the place where the new happens?
|
||||
throw DatabaseExceptionFactory::create($e);
|
||||
$exception = DatabaseExceptionFactory::createException($e);
|
||||
$message = DatabaseExceptionFactory::createExceptionMessage($e);
|
||||
|
||||
throw new $exception($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class DatabaseExceptionFactory
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function create(\PDOException $e) : \PDOException
|
||||
public static function createException(\PDOException $e) : \PDOException
|
||||
{
|
||||
switch ($e->getCode()) {
|
||||
case '42S02':
|
||||
|
|
@ -47,6 +47,25 @@ class DatabaseExceptionFactory
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \PDOException $e Exception
|
||||
*
|
||||
* @return \PDOException
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function createExceptionMessage(\PDOException $e) : \PDOException
|
||||
{
|
||||
switch ($e->getCode()) {
|
||||
case '42S02':
|
||||
return self::createTableViewExceptionMessage($e);
|
||||
default:
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create table exception.
|
||||
*
|
||||
|
|
@ -56,8 +75,8 @@ class DatabaseExceptionFactory
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createTableViewException(\PDOException $e) : \PDOException
|
||||
private static function createTableViewException(\PDOException $e) : string
|
||||
{
|
||||
return new TableException(TableException::findTable($e->getMessage()));
|
||||
return TableException::findTable($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user