TelegramException.php 914 Bytes
Newer Older
LONGMAN's avatar
LONGMAN committed
1
<?php
2
/**
LONGMAN's avatar
LONGMAN committed
3 4 5 6 7 8
 * This file is part of the TelegramBot package.
 *
 * (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
9 10
 */

LONGMAN's avatar
LONGMAN committed
11 12
namespace Longman\TelegramBot\Exception;

13 14 15
/**
 * Main exception class used for exception handling
 */
LONGMAN's avatar
LONGMAN committed
16 17
class TelegramException extends \Exception
{
18
    /**
19
     * Exception constructor that writes the exception message to the logfile
20
     *
21 22
     * @param string  $message Error message
     * @param integer $code    Error code
23
     */
24 25 26 27 28
    public function __construct($message, $code = 0)
    {
        parent::__construct($message, $code);

        $path = 'TelegramException.log';
29 30
        $status = file_put_contents(
            $path,
31
            date('Y-m-d H:i:s', time()) . ' ' . self::__toString() . "\n",
32 33
            FILE_APPEND
        );
34
    }
LONGMAN's avatar
LONGMAN committed
35
}