Handle exceptions.
This commit is contained in:
parent
65be21e0ab
commit
b51828ba2f
6
chat.php
6
chat.php
@ -35,16 +35,16 @@ function show_messages()
|
|||||||
FROM `chat` ORDER BY `id` LIMIT 50');
|
FROM `chat` ORDER BY `id` LIMIT 50');
|
||||||
} catch (\Krugozor\Database\Mysql\Exception $e) {
|
} catch (\Krugozor\Database\Mysql\Exception $e) {
|
||||||
echo "DB Error: ". $e->getMessage() . PHP_EOL;
|
echo "DB Error: ". $e->getMessage() . PHP_EOL;
|
||||||
echo "File: " . $e->getFile() . "[".$e->getLine()."]". PHP_EOL;
|
echo "File: " . $e->getFile() . " (".$e->getLine().")". PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($message = $chat->fetch_assoc()) {
|
while ($message = $chat->fetch_assoc()) {
|
||||||
$d = new DateTime($message['msgdate']);
|
$d = new DateTime($message['msgdate']);
|
||||||
$m = htmlspecialchars($message['msg']);
|
$m = htmlspecialchars($message['msg']);
|
||||||
if ($message['type'] == 'sys') { /* Системка */
|
if ($message['type'] == 'sys') { /* Системка */
|
||||||
echo sprintf('<span style="color:maroon;background:#faa;">%s %s</span>', $d->format('H:i'),$m).PHP_EOL;
|
echo sprintf("<span style='color:maroon;background:#faa;'>%s %s</span>", $d->format('H:i'),$m).PHP_EOL;
|
||||||
} elseif ($message['type'] == 'sms') { /* Телеграмма */
|
} elseif ($message['type'] == 'sms') { /* Телеграмма */
|
||||||
echo sprintf('<span style="color:darkgreen;background:#afa;">[Телеграмма]: %s %s</span>', $d->format('H:i'),$m).PHP_EOL;
|
echo sprintf("<span style='color:darkgreen;background:#afa;'>[Телеграмма]: %s %s</span>", $d->format('H:i'),$m).PHP_EOL;
|
||||||
} else {echo sprintf('%s [%s]: %s', $d->format('H:i'),$message['from'],$m).PHP_EOL;}
|
} else {echo sprintf('%s [%s]: %s', $d->format('H:i'),$message['from'],$m).PHP_EOL;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user