Add classes and tests from common project
This commit is contained in:
30
src/DocumentException.php
Normal file
30
src/DocumentException.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user