49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace core\exception;
|
|
|
|
abstract class CustomException extends \Exception
|
|
{
|
|
/**
|
|
* default tags associated to this exception
|
|
*
|
|
* @var \class[]
|
|
*/
|
|
const TAGS = [];
|
|
|
|
/**
|
|
* CustomException constructor
|
|
*
|
|
* @param ?\string $message Error message (default to null)
|
|
*
|
|
* @param \int $code User defined code (default to 0)
|
|
*
|
|
* @param ?\Throwable $previous throwable (default to null)
|
|
*
|
|
* @param ?\array $tags Tags of the generated log event (default to null)
|
|
*/
|
|
public function __construct(?\string $message = null, \int $code = 0, ?\Throwable $previous = null, ?\array $tags = null)
|
|
{
|
|
if (\is_null($message))
|
|
{
|
|
$message = _("empty message")
|
|
}
|
|
if (\is_null($tags))
|
|
{
|
|
$tags = $this::TAGS;
|
|
}
|
|
|
|
parent::__construct($message, $code, $previous);
|
|
}
|
|
|
|
public funtion __tostring() : string
|
|
{
|
|
return \htmlspecialchars(\get_class($this)) .
|
|
' ' . \htmlspecialchars($this->message) .
|
|
' in ' . \htmlspecialchars($this->file) .
|
|
'(' . \htmlspecialchars($this->line) . ')\n' .
|
|
\htmlspecialchars($this->getTraceAsString());
|
|
}
|
|
}
|
|
|
|
?>
|