| 1 |
<?php |
| 2 |
|
| 3 |
namespace SlimStat\Exception; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
use wp_slimstat as SlimStat; |
| 7 |
|
| 8 |
class LogException extends Exception |
| 9 |
{ |
| 10 |
public function __construct($message, $code = 0, ?Exception $previous = null) |
| 11 |
{ |
| 12 |
parent::__construct($message, $code, $previous); |
| 13 |
|
| 14 |
SlimStat::log($this->generateLogMessage($message, $code), 'error'); |
| 15 |
} |
| 16 |
|
| 17 |
private function generateLogMessage($message, $code) |
| 18 |
{ |
| 19 |
return sprintf( |
| 20 |
__('Exception occurred: [Code %d] %s at %s:%d', 'wp-slimstat'), |
| 21 |
$code, |
| 22 |
$message, |
| 23 |
$this->getFile(), |
| 24 |
$this->getLine() |
| 25 |
); |
| 26 |
} |
| 27 |
} |
| 28 |
|