PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.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 All 257 releases
give / src / Framework / Database / Exceptions / DatabaseQueryException.php

DatabaseQueryException.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at src/Framework/Database/Exceptions/DatabaseQueryException.php

76 lines 1.6 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 4.17.0 Declare the nullable parameter explicitly.
31 * @since 2.21.0 include query and query errors, and make auto-logging compatible
32 * @since 2.9.2
33 */
34 public function __construct(
35 string $query,
36 array $queryErrors,
37 string $message = 'Database Query',
38 $code = 0,
39 ?Throwable $previous = null
40 ) {
41 $this->query = $query;
42 $this->queryErrors = $queryErrors;
43
44 parent::__construct($message, $code, $previous);
45 }
46
47 /**
48 * Returns the query errors
49 *
50 * @since 2.9.2
51 *
52 * @return string[]
53 */
54 public function getQueryErrors(): array
55 {
56 return $this->queryErrors;
57 }
58
59 public function getQuery(): string
60 {
61 return $this->query;
62 }
63
64 /**
65 * @inheritDoc
66 */
67 public function getLogContext(): array
68 {
69 return [
70 'category' => 'Uncaught database exception',
71 'Query' => $this->query,
72 'Query Errors' => $this->queryErrors,
73 ];
74 }
75 }
76