refactoring database and error classes.
This commit is contained in:
parent
d72f2c642b
commit
b196313bd0
|
@ -20,10 +20,7 @@ class DB {
|
||||||
*/
|
*/
|
||||||
public static function connection($connection = null)
|
public static function connection($connection = null)
|
||||||
{
|
{
|
||||||
if (is_null($connection))
|
if (is_null($connection)) $connection = Config::get('db.default');
|
||||||
{
|
|
||||||
$connection = Config::get('db.default');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! array_key_exists($connection, static::$connections))
|
if ( ! array_key_exists($connection, static::$connections))
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,7 +38,7 @@ public static function handle($e)
|
||||||
|
|
||||||
$severity = (array_key_exists($e->getCode(), static::$levels)) ? static::$levels[$e->getCode()] : $e->getCode();
|
$severity = (array_key_exists($e->getCode(), static::$levels)) ? static::$levels[$e->getCode()] : $e->getCode();
|
||||||
|
|
||||||
$message = rtrim($e->getMessage(), '.').' in '.str_replace(array(APP_PATH, SYS_PATH), array('APP_PATH/', 'SYS_PATH/'), $e->getFile()).' on line '.$e->getLine().'.';
|
$message = static::format($e);
|
||||||
|
|
||||||
if (Config::get('error.log'))
|
if (Config::get('error.log'))
|
||||||
{
|
{
|
||||||
|
@ -50,6 +50,19 @@ public static function handle($e)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the error message for a given exception.
|
||||||
|
*
|
||||||
|
* @param Exception $e
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function format($e)
|
||||||
|
{
|
||||||
|
$file = str_replace(array(APP_PATH, SYS_PATH), array('APP_PATH/', 'SYS_PATH/'), $e->getFile());
|
||||||
|
|
||||||
|
return rtrim($e->getMessage(), '.').' in '.$file.' on line '.$e->getLine().'.';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the error view.
|
* Show the error view.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue