diff --git a/conlite/classes/Exceptions/FileNotFoundException.php b/conlite/classes/Exceptions/FileNotFoundException.php new file mode 100644 index 0000000..bf27e24 --- /dev/null +++ b/conlite/classes/Exceptions/FileNotFoundException.php @@ -0,0 +1,8 @@ +createHandle(); + } + + /** + * @param string $message + * @param int $priority + * @return bool + */ + public function write($message, $priority): bool + { + return fwrite($this->handle, $message) != false; + } + + /** + * @throws Exception + * @throws FileNotFoundException + */ + protected function createHandle(): void + { + $destination = $this->getOption('destination'); + if ($destination == '') { + throw new Exception('No destination was specified.'); + } + + if (($this->handle = fopen($destination, 'a')) === false) { + throw new FileNotFoundException('Destination handle could not be created.'); + } + } } \ No newline at end of file