mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-04-22 19:02:12 +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 Exception;
|
||||
use DeltaCMS\Exception\FileException;
|
||||
|
||||
class Logger extends AbstractLogger
|
||||
{
|
||||
@ -28,11 +29,14 @@ class Logger extends AbstractLogger
|
||||
public function __construct($file = "./logs.log")
|
||||
{
|
||||
if (!file_exists($file)) {
|
||||
$ressource = fopen($file, 'w');
|
||||
if ($ressource === false) {
|
||||
throw new Exception("File at " . $file . " can't be created. exiting", 1);
|
||||
try {
|
||||
$ressource = fopen($file, 'w');
|
||||
if ($ressource !== false) {
|
||||
fclose($ressource);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new FileException("File can't be created");
|
||||
}
|
||||
fclose($ressource);
|
||||
}
|
||||
$this->file = $file;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user