]> git.openstreetmap.org Git - nominatim.git/blob - lib/DatabaseError.php
website dependencies: jQuery v2.1 => 3.5, leaflet 1.3 => 1.6
[nominatim.git] / lib / DatabaseError.php
1 <?php
2
3 namespace Nominatim;
4
5 class DatabaseError extends \Exception
6 {
7
8     public function __construct($message, $code = 500, Exception $previous = null, $oPDOErr, $sSql = null)
9     {
10         parent::__construct($message, $code, $previous);
11         // https://secure.php.net/manual/en/class.pdoexception.php
12         $this->oPDOErr = $oPDOErr;
13         $this->sSql = $sSql;
14     }
15
16     public function __toString()
17     {
18         return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
19     }
20
21     public function getSqlError()
22     {
23         return $this->oPDOErr->getMessage();
24     }
25
26     public function getSqlDebugDump()
27     {
28         if (CONST_Debug) {
29             return var_export($this->oPDOErr, true);
30         } else {
31             return $this->sSql;
32         }
33     }
34 }