mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-04-23 03:12:14 +00:00
Added exception when file could not be created
This commit is contained in:
parent
c71600aa66
commit
37f62ba892
9
src/DeltaCMS/Exception/FileException.php
Normal file
9
src/DeltaCMS/Exception/FileException.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DeltaCMS\Exception;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class FileException extends Exception
|
||||||
|
{
|
||||||
|
}
|
@ -6,6 +6,7 @@ use Psr\Log\AbstractLogger;
|
|||||||
use Psr\Log\InvalidArgumentException;
|
use Psr\Log\InvalidArgumentException;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use DeltaCMS\Exception\FileException;
|
||||||
|
|
||||||
class Logger extends AbstractLogger
|
class Logger extends AbstractLogger
|
||||||
{
|
{
|
||||||
@ -28,11 +29,14 @@ class Logger extends AbstractLogger
|
|||||||
public function __construct($file = "./logs.log")
|
public function __construct($file = "./logs.log")
|
||||||
{
|
{
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
$ressource = fopen($file, 'w');
|
try {
|
||||||
if ($ressource === false) {
|
$ressource = fopen($file, 'w');
|
||||||
throw new Exception("File at " . $file . " can't be created. exiting", 1);
|
if ($ressource !== false) {
|
||||||
|
fclose($ressource);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new FileException("File can't be created");
|
||||||
}
|
}
|
||||||
fclose($ressource);
|
|
||||||
}
|
}
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user