pdo-document/src/DocumentException.php

31 lines
806 B
PHP

<?php declare(strict_types=1);
namespace BitBadger\PDODocument;
use Exception;
use Throwable;
/**
* Exceptions occurring during document processing
*/
class DocumentException extends Exception
{
/**
* Constructor
*
* @param string $message A message for the exception
* @param int $code The code for the exception (optional; defaults to 0)
* @param Throwable|null $previous The previous exception (optional; defaults to `null`)
*/
public function __construct(string $message, int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
public function __toString(): string
{
$codeStr = $this->code == 0 ? '' : "[$this->code] ";
return __CLASS__ . ": $codeStr$this->message\n";
}
}