2 declare(strict_types=1);
4 namespace Friendica\Database;
10 * A database fatal exception, which shouldn't occur
12 class DatabaseException extends Exception
17 * Construct the exception. Note: The message is NOT binary safe.
19 * @link https://php.net/manual/en/exception.construct.php
21 * @param string $message The Database error message.
22 * @param int $code The Database error code.
23 * @param string $query The Database error query.
24 * @param Throwable $previous [optional] The previous throwable used for the exception chaining.
26 public function __construct(string $message, int $code, string $query, Throwable $previous = null)
28 parent::__construct($message, $code, $previous);
29 $this->query = $query;
35 public function __toString()
37 return sprintf('Database error %d "%s" at "%s"', $this->message, $this->code, $this->query);