]> git.openstreetmap.org Git - nominatim.git/blob - lib-php/DatabaseError.php
reintroduce cutoffs when searching for very frequent words
[nominatim.git] / lib-php / DatabaseError.php
1 <?php
2 /**
3  * SPDX-License-Identifier: GPL-2.0-only
4  *
5  * This file is part of Nominatim. (https://nominatim.org)
6  *
7  * Copyright (C) 2022 by the Nominatim developer community.
8  * For a full list of authors see the git log.
9  */
10
11 namespace Nominatim;
12
13 class DatabaseError extends \Exception
14 {
15
16     public function __construct($message, $code, $previous, $oPDOErr, $sSql = null)
17     {
18         parent::__construct($message, $code, $previous);
19         // https://secure.php.net/manual/en/class.pdoexception.php
20         $this->oPDOErr = $oPDOErr;
21         $this->sSql = $sSql;
22     }
23
24     public function __toString()
25     {
26         return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
27     }
28
29     public function getSqlError()
30     {
31         return $this->oPDOErr->getMessage();
32     }
33
34     public function getSqlDebugDump()
35     {
36         if (CONST_Debug) {
37             return var_export($this->oPDOErr, true);
38         } else {
39             return $this->sSql;
40         }
41     }
42 }