PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 3.21.1
GiveWP – Donation Plugin and Fundraising Platform v3.21.1
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Framework / Database / Exceptions / DatabaseQueryException.php
DatabaseQueryException.php
75 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Framework\Database\Exceptions;
4
5 use Give\Framework\Exceptions\Primitives\Exception;
6 use Throwable;
7
8 /**
9 * Class DatabaseQueryException
10 *
11 * An exception for when errors occurred within the database while performing a query, which stores the SQL errors the
12 * database returned
13 *
14 * @since 2.21.0 Use the GiveWP exception class
15 * @since 2.9.2
16 */
17 class DatabaseQueryException extends Exception
18 {
19 /**
20 * @var string[]
21 */
22 private $queryErrors;
23
24 /**
25 * @var string
26 */
27 private $query;
28
29 /**
30 * @since 2.21.0 include query and query errors, and make auto-logging compatible
31 * @since 2.9.2
32 */
33 public function __construct(
34 string $query,
35 array $queryErrors,
36 string $message = 'Database Query',
37 $code = 0,
38 Throwable $previous = null
39 ) {
40 $this->query = $query;
41 $this->queryErrors = $queryErrors;
42
43 parent::__construct($message, $code, $previous);
44 }
45
46 /**
47 * Returns the query errors
48 *
49 * @since 2.9.2
50 *
51 * @return string[]
52 */
53 public function getQueryErrors(): array
54 {
55 return $this->queryErrors;
56 }
57
58 public function getQuery(): string
59 {
60 return $this->query;
61 }
62
63 /**
64 * @inheritDoc
65 */
66 public function getLogContext(): array
67 {
68 return [
69 'category' => 'Uncaught database exception',
70 'Query' => $this->query,
71 'Query Errors' => $this->queryErrors,
72 ];
73 }
74 }
75